class YARD::Server::RackMiddleware
use YARD::Server::RackMiddleware, :libraries => libraries
libraries = {:mylib => [YARD::Server::LibraryVersion.new(‘mylib’, nil, ‘/path/to/.yardoc’)]}
@example Using the RackMiddleware in a Rack application
at the example below.
read about how to return a list of libraries, see {LibraryVersion} or look
@note You must pass a :libraries
option to the RackMiddleware via #use
. To
See {#initialize} for a list of options to pass via Rack’s #use
method.
This class wraps the {RackAdapter} into a Rack-compatible middleware.
def call(env)
def call(env) status, headers, body = *@adapter.call(env) if status == 404 @app.call(env) else [status, headers, body] end end
def initialize(app, opts = {})
(**opts)
-
:server_options
(Hash
) -- a list of options to pass to the server. -
:options
(Hash
) -- a list of options to pass to the adapter. -
:libraries
(Hash{String=>Array
) --}
Parameters:
-
app
() -- the next Rack middleware in the stack
def initialize(app, opts = {}) args = [opts[:libraries] || {}, opts[:options] || {}, opts[:server_options] || {}] @app = app @adapter = RackAdapter.new(*args) end