All Projects → anycable → anycable-rack-server

anycable / anycable-rack-server

Licence: MIT license
AnyCable-compatible Ruby Rack middleware

Programming Languages

ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to anycable-rack-server

Sham rack
run Rack applications in-process, without a server
Stars: ✭ 169 (+704.76%)
Mutual labels:  rack
Rack Reducer
Declaratively filter data via URL params, in any Rack app, with any ORM.
Stars: ✭ 241 (+1047.62%)
Mutual labels:  rack
grape-jwt-authentication
A reusable Grape JWT authentication concern
Stars: ✭ 31 (+47.62%)
Mutual labels:  rack
Thin
A very fast & simple Ruby web server
Stars: ✭ 2,170 (+10233.33%)
Mutual labels:  rack
Split
📈 The Rack Based A/B testing framework
Stars: ✭ 2,539 (+11990.48%)
Mutual labels:  rack
Slide
MasahiroSaito's Slides Repository
Stars: ✭ 12 (-42.86%)
Mutual labels:  rack
Prax.cr
Rack proxy server for development (Crystal port)
Stars: ✭ 142 (+576.19%)
Mutual labels:  rack
anycable-helm
Helm charts for installing any cables into a Kubernetes cluster
Stars: ✭ 14 (-33.33%)
Mutual labels:  anycable
Plezi
Plezi - the Ruby framework for realtime web-apps, websockets and RESTful HTTP
Stars: ✭ 239 (+1038.1%)
Mutual labels:  rack
dyndnsd
A small, lightweight and extensible DynDNS server written with Ruby and Rack.
Stars: ✭ 69 (+228.57%)
Mutual labels:  rack
Trashed
Tell StatsD about request time, GC, objects and more. Latest Rails 4 and Ruby 2.1 support, and ancient Rails 2 and Ruby 1.8 support.
Stars: ✭ 188 (+795.24%)
Mutual labels:  rack
Controller
Complete, fast and testable actions for Rack and Hanami
Stars: ✭ 221 (+952.38%)
Mutual labels:  rack
tipi
Tipi - the All-in-one Web Server for Ruby Apps
Stars: ✭ 214 (+919.05%)
Mutual labels:  rack
Rack csrf
Anti-CSRF Rack middleware
Stars: ✭ 169 (+704.76%)
Mutual labels:  rack
rack-cargo
🚚 Batch requests for Rack apps (works with Rails, Sinatra, etc)
Stars: ✭ 17 (-19.05%)
Mutual labels:  rack
Sinatra
Classy web-development dressed in a DSL (official / canonical repo)
Stars: ✭ 11,497 (+54647.62%)
Mutual labels:  rack
rack-session-smart cookie
Slightly smarter session cookies for Rack 2 apps
Stars: ✭ 43 (+104.76%)
Mutual labels:  rack
rack-queries
A page in your rack-based application that allows quick execution of pre-built queries
Stars: ✭ 25 (+19.05%)
Mutual labels:  rack
itop-datacenter-view
Extension for iTop: Easily manage & visualize your racks, enclosures and datacenter devices.
Stars: ✭ 24 (+14.29%)
Mutual labels:  rack
rack-reproxy
Transparently proxy Rack responses from a backend URL. Great for private access to an internal service or to route authenticated requests through intermediate caching layers.
Stars: ✭ 20 (-4.76%)
Mutual labels:  rack

Cult Of Martians Gem Version Build

anycable-rack-server

AnyCable-compatible Rack hijack based Ruby Web Socket server designed for development and testing purposes.

Using with Rack

# Initialize server instance first.
ws_server = AnyCable::Rack::Server.new

app = Rack::Builder.new do
  map "/cable" do
    run ws_server
  end
end

# NOTE: don't forget to call `start!` method
ws_server.start!

run app

Usage with Rails

Add 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.

Configuration

AnyCable Rack Server uses 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.

NOTE: AnyCable Rack Server uses the same config name (i.e., env prefix, YML file name, etc.) as AnyCable itself.

You can pass a config object as the option to AnyCable::Rack::Server.new:

server = AnyCable::Server::Rack.new(config: AnyCable::Rack::Config.new(**params))

If no config is passed, a default, global, configuration would be used (AnyCable::Rack.config).

When using Rails, config.anycable_rack points to AnyCable::Rack.config.

Headers

You can customize the headers being sent with each gRPC request.

Default headers: 'cookie', 'x-api-token'.

Can be specified via configuration:

AnyCable::Rack.config.headers = ["cookie", "x-my-header"]

Or in Rails:

# <environment>.rb
config.any_cable_rack.headers = %w[cookie]

Rails-specific options

# Mount WebSocket server at the specified path
config.any_cable_rack.mount_path = "/cable"
# NOTE: here we specify only the port (we assume that a server is running locally)
config.any_cable_rack.rpc_port = 50051

Broadcast adapters

AnyCable Rack supports Redis (default) and HTTP broadcast adapters (see the documentation).

Broadcast adapter is inherited from AnyCable configuration (so, you don't need to configure it twice).

Using HTTP broadcast adapter

With Rack

AnyCable::Rack.config.broadast_adapter = :http

ws_server = AnyCable::Rack::Server

app = Rack::Builder.new do
  map "/cable" do
    run ws_server
  end

  map "/_anycable_rack_broadcast" do
    run ws_server.broadcast
  end
end

With Rails

By default, we mount broadcasts endpoint at /_anycable_rack_broadcast.

You can change this setting:

config.any_cable_rack.http_broadcast_path = "/_my_broadcast"

NOTE: Don't forget to configure http_broadcast_url for AnyCable pointing to your web server and the specified broadcast path.

Testing

Run units with bundle exec rake.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/anycable/anycable-rack-server.

License

The gem is available as open source under the terms of the MIT License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].