{"id":19522306,"url":"https://github.com/anycable/anycable-rack-server","last_synced_at":"2025-04-26T09:32:08.095Z","repository":{"id":39793682,"uuid":"159983811","full_name":"anycable/anycable-rack-server","owner":"anycable","description":"AnyCable-compatible Ruby Rack middleware","archived":false,"fork":false,"pushed_at":"2023-06-30T01:37:45.000Z","size":128,"stargazers_count":26,"open_issues_count":0,"forks_count":14,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-04T10:37:07.360Z","etag":null,"topics":["anycable","rack","ruby"],"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/anycable.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","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},"funding":{"github":"anycable"}},"created_at":"2018-12-01T20:20:26.000Z","updated_at":"2025-02-21T20:19:48.000Z","dependencies_parsed_at":"2024-11-11T00:38:32.542Z","dependency_job_id":"802a85a5-454b-4154-8b22-76d97c1ac1a9","html_url":"https://github.com/anycable/anycable-rack-server","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anycable%2Fanycable-rack-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anycable%2Fanycable-rack-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anycable%2Fanycable-rack-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anycable%2Fanycable-rack-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/anycable","download_url":"https://codeload.github.com/anycable/anycable-rack-server/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250967251,"owners_count":21515565,"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":["anycable","rack","ruby"],"created_at":"2024-11-11T00:38:24.649Z","updated_at":"2025-04-26T09:32:07.806Z","avatar_url":"https://github.com/anycable.png","language":"Ruby","readme":"[![Cult Of Martians](http://cultofmartians.com/assets/badges/badge.svg)](https://cultofmartians.com/tasks/anycable-ruby-server.html)\n[![Gem Version](https://badge.fury.io/rb/anycable-rack-server.svg)](https://rubygems.org/gems/anycable-rack-server)\n[![Build](https://github.com/anycable/anycable-rack-server/workflows/Build/badge.svg)](https://github.com/anycable/anycable-rack-server/actions)\n\n# anycable-rack-server\n\n[AnyCable](https://anycable.io)-compatible Rack hijack based Ruby Web Socket server designed for development and testing purposes.\n\n## Using with Rack\n\n```ruby\n# Initialize server instance first.\nws_server = AnyCable::Rack::Server.new\n\napp = Rack::Builder.new do\n  map \"/cable\" do\n    run ws_server\n  end\nend\n\n# NOTE: don't forget to call `start!` method\nws_server.start!\n\nrun app\n```\n\n## Usage with Rails\n\nAdd `gem \"anycable-rack-server\"` to you `Gemfile` and make sure your Action Cable adapter is set to `:any_cable`. That's it! We automatically start AnyCable Rack server for you at `/cable` path.\n\n## Configuration\n\nAnyCable Rack Server uses [`anyway_config`](https://github.com/palkan/anyway_config) gem for configuration; thus it is possible to set configuration parameters through environment vars (prefixed with `ANYCABLE_`), `config/anycable.yml` file or `secrets.yml` when using Rails.\n\n**NOTE:** AnyCable Rack Server uses the same config name (i.e., env prefix, YML file name, etc.) as AnyCable itself.\n\nYou can pass a config object as the option to `AnyCable::Rack::Server.new`:\n\n```ruby\nserver = AnyCable::Server::Rack.new(config: AnyCable::Rack::Config.new(**params))\n```\n\nIf no config is passed, a default, global, configuration would be used (`AnyCable::Rack.config`).\n\nWhen using Rails, `config.anycable_rack` points to `AnyCable::Rack.config`.\n\n### Headers\n\nYou can customize the headers being sent with each gRPC request.\n\nDefault headers: `'cookie', 'x-api-token'`.\n\nCan be specified via configuration:\n\n```ruby\nAnyCable::Rack.config.headers = [\"cookie\", \"x-my-header\"]\n```\n\nOr in Rails:\n\n```ruby\n# \u003cenvironment\u003e.rb\nconfig.any_cable_rack.headers = %w[cookie]\n```\n\n### Rails-specific options\n\n```ruby\n# Mount WebSocket server at the specified path\nconfig.any_cable_rack.mount_path = \"/cable\"\n# NOTE: here we specify only the port (we assume that a server is running locally)\nconfig.any_cable_rack.rpc_port = 50051\n```\n\n## Broadcast adapters\n\nAnyCable Rack supports Redis (default) and HTTP broadcast adapters\n(see [the documentation](https://docs.anycable.io/ruby/broadcast_adapters)).\n\nBroadcast adapter is inherited from AnyCable configuration (so, you don't need to configure it twice).\n\n### Using HTTP broadcast adapter\n\n### With Rack\n\n```ruby\nAnyCable::Rack.config.broadast_adapter = :http\n\nws_server = AnyCable::Rack::Server\n\napp = Rack::Builder.new do\n  map \"/cable\" do\n    run ws_server\n  end\n\n  map \"/_anycable_rack_broadcast\" do\n    run ws_server.broadcast\n  end\nend\n```\n\n### With Rails\n\nBy default, we mount broadcasts endpoint at `/_anycable_rack_broadcast`.\n\nYou can change this setting:\n\n```ruby\nconfig.any_cable_rack.http_broadcast_path = \"/_my_broadcast\"\n```\n\n**NOTE:** Don't forget to configure `http_broadcast_url` for AnyCable pointing to your web server and the specified broadcast path.\n\n## Testing\n\nRun units with `bundle exec rake`.\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at [https://github.com/anycable/anycable-rack-server](https://github.com/anycable/anycable-rack-server).\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](./LICENSE).\n","funding_links":["https://github.com/sponsors/anycable"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanycable%2Fanycable-rack-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fanycable%2Fanycable-rack-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanycable%2Fanycable-rack-server/lists"}