Skip to content

Latest commit

 

History

History
41 lines (30 loc) · 2.16 KB

adapters.md

File metadata and controls

41 lines (30 loc) · 2.16 KB

Adapters

Webmachine includes adapters for WEBrick, Reel, and HTTPkit. Additionally, the Rack adapter lets it run on any webserver that provides a Rack interface. It also lets it run on Shotgun (example).

A Note about Rack

In order to be compatible with popular deployment stacks, Webmachine has a Rack adapter (thanks to Jamis Buck).

Webmachine can be used with Rack middlware features such as Rack::Map and Rack::Cascade as long as any requests/responses that are handled by the Webmachine app are not modified by the middleware. The behaviours that are encapsulated in Webmachine assume that no modifications are done to requests or response outside of Webmachine.

Keep in mind that Webmachine already supports many things that Rack middleware is used for with other HTTP frameworks (eg. etags, specifying supported/preferred Accept and Content-Types).

The base Webmachine::Adapters::Rack class assumes the Webmachine application is mounted at the route path / (i.e. not using Rack::Builder#map or Rails ActionDispatch::Routing::Mapper::Base#mount). In order to map to a subpath, use the Webmachine::Adapters::RackMapped adapter instead.

For an example of using Webmachine with Rack middleware, see the Pact Broker.

See the Rack Adapter API docs for more information.

A Note about MRI 1.9

The Reel and HTTPkit adapters might crash with a SystemStackError on MRI 1.9 due to its limited fiber stack size. If your application is affected by this, the only known solution is to switch to JRuby, Rubinius or MRI 2.0.