Skip to content

Commit c288d08

Browse files
committed
added comments around RackMapped
1 parent 7e0c4dc commit c288d08

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

lib/webmachine/adapters/rack.rb

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,12 @@ module Adapters
1212
# A minimal "shim" adapter to allow Webmachine to interface with Rack. The
1313
# intention here is to allow Webmachine to run under Rack-compatible
1414
# web-servers, like unicorn and pow.
15+
#
1516
# The adapter expects your Webmachine application to be mounted at the root path -
1617
# it will NOT allow you to nest your Webmachine application at an arbitrary path
1718
# eg. map "/api" { run MyWebmachineAPI }
19+
# To use map your Webmachine application at an arbitrary path, use the
20+
# `Webmachine::Adapters::RackMapped` subclass instead.
1821
#
1922
# To use this adapter, create a config.ru file and populate it like so:
2023
#
@@ -179,6 +182,24 @@ def each
179182
end # class RequestBody
180183
end # class Rack
181184

185+
# Provides the same functionality as the parent Webmachine::Adapters::Rack
186+
# adapter, but allows the Webmachine application to be hosted at an
187+
# arbitrary path in a parent Rack application (as in Rack `map` or Rails
188+
# routing `mount`)
189+
#
190+
# This functionality is separated out from the parent class to preserve
191+
# backward compatibility in the behaviour of the parent Rack adpater.
192+
#
193+
# To use the adapter in a parent Rack application, map the Webmachine
194+
# application as follows in a rackup file or Rack::Builder:
195+
#
196+
# map '/foo' do
197+
# run SomeotherRackApp
198+
#
199+
# map '/bar' do
200+
# run MyWebmachineApp.adapter
201+
# end
202+
# end
182203
class RackMapped < Rack
183204
protected
184205
def routing_tokens(rack_req)

0 commit comments

Comments
 (0)