{"id":19315990,"url":"https://github.com/socketry/protocol-rack","last_synced_at":"2025-04-22T16:32:53.234Z","repository":{"id":57750178,"uuid":"524578254","full_name":"socketry/protocol-rack","owner":"socketry","description":null,"archived":false,"fork":false,"pushed_at":"2024-11-09T12:21:22.000Z","size":196,"stargazers_count":4,"open_issues_count":3,"forks_count":2,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-11-09T13:23:53.088Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/socketry.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"license.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-08-14T05:07:43.000Z","updated_at":"2024-11-09T12:21:25.000Z","dependencies_parsed_at":"2024-04-03T00:31:05.049Z","dependency_job_id":"6213fdb6-3715-414a-ab26-44d04ee707cd","html_url":"https://github.com/socketry/protocol-rack","commit_stats":{"total_commits":46,"total_committers":1,"mean_commits":46.0,"dds":0.0,"last_synced_commit":"708582d65242ee0d1a512073a631e798a49f03ba"},"previous_names":[],"tags_count":28,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/socketry%2Fprotocol-rack","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/socketry%2Fprotocol-rack/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/socketry%2Fprotocol-rack/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/socketry%2Fprotocol-rack/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/socketry","download_url":"https://codeload.github.com/socketry/protocol-rack/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223900220,"owners_count":17222028,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-10T01:09:18.929Z","updated_at":"2025-04-22T16:32:53.226Z","avatar_url":"https://github.com/socketry.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Protocol::Rack\n\nProvides abstractions for working with the Rack specification on top of [`Protocol::HTTP`](https://github.com/socketry/protocol-http). This would, in theory, allow you to run any `Protocol::HTTP` compatible application on top any rack-compatible server.\n\n[![Development Status](https://github.com/socketry/protocol-rack/workflows/Test/badge.svg)](https://github.com/socketry/protocol-rack/actions?workflow=Test)\n\n## Features\n\n  - Supports Rack v2 and Rack v3 application adapters.\n  - Supports Rack environment to `Protocol::HTTP::Request` adapter.\n\n## Usage\n\nPlease see the [project documentation](https://socketry.github.io/protocol-rack/) for more details.\n\n### Application Adapter\n\nGiven a rack application, you can adapt it for use on `async-http`:\n\n``` ruby\nrequire 'async'\nrequire 'async/http/server'\nrequire 'async/http/client'\nrequire 'async/http/endpoint'\nrequire 'protocol/rack/adapter'\n\napp = proc{|env| [200, {}, [\"Hello World\"]]}\nmiddleware = Protocol::Rack::Adapter.new(app)\n\nAsync do\n  endpoint = Async::HTTP::Endpoint.parse(\"http://localhost:9292\")\n  \n  server_task = Async(transient: true) do\n    server = Async::HTTP::Server.new(middleware, endpoint)\n    server.run\n  end\n  \n  client = Async::HTTP::Client.new(endpoint)\n  puts client.get(\"/\").read\n  # \"Hello World\"\nend\n```\n\n### Server Adapter\n\nWhile not tested, in theory any Rack compatible server can host `Protocol::HTTP` compatible middlewares.\n\n``` ruby\nrequire 'protocol/http/middleware'\nrequire 'protocol/rack'\n\n# Your native application:\nmiddleware = Protocol::HTTP::Middleware::HelloWorld\n\nrun proc{|env|\n  # Convert the rack request to a compatible rich request object:\n  request = Protocol::Rack::Request[env]\n  \n  # Call your application\n  response = middleware.call(request)\n  \n  Protocol::Rack::Adapter.make_response(env, response)\n}\n```\n\n## Releases\n\nPlease see the [project releases](https://socketry.github.io/protocol-rack/releases/index) for all releases.\n\n### v0.11.2\n\n  - Stop setting `env[\"SERVER_PORT\"]` to `nil` if not present.\n\n## Contributing\n\nWe welcome contributions to this project.\n\n1.  Fork it.\n2.  Create your feature branch (`git checkout -b my-new-feature`).\n3.  Commit your changes (`git commit -am 'Add some feature'`).\n4.  Push to the branch (`git push origin my-new-feature`).\n5.  Create new Pull Request.\n\n### Developer Certificate of Origin\n\nIn order to protect users of this project, we require all contributors to comply with the [Developer Certificate of Origin](https://developercertificate.org/). This ensures that all contributions are properly licensed and attributed.\n\n### Community Guidelines\n\nThis project is best served by a collaborative and respectful environment. Treat each other professionally, respect differing viewpoints, and engage constructively. Harassment, discrimination, or harmful behavior is not tolerated. Communicate clearly, listen actively, and support one another. If any issues arise, please inform the project maintainers.\n\n## See Also\n\n  - [protocol-http](https://github.com/socketry/protocol-http) — General abstractions for HTTP client/server implementations.\n  - [async-http](https://github.com/socketry/async-http) — Asynchronous HTTP client and server, supporting multiple HTTP protocols \u0026 TLS, which can host the Rack application adapters (and is used by this gem for testing).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsocketry%2Fprotocol-rack","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsocketry%2Fprotocol-rack","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsocketry%2Fprotocol-rack/lists"}