Class: YARD::Server::RackMiddleware
- Inherits:
-
Object
- Object
- YARD::Server::RackMiddleware
- Defined in:
- lib/yard/server/rack_adapter.rb
Overview
Note:
You must pass a :libraries
option to the RackMiddleware via #use
. To read about how to return a list of libraries, see LibraryVersion or look at the example below.
This class wraps the RackAdapter into a Rack-compatible middleware. See #initialize for a list of options to pass via Rack’s #use
method.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, opts = {}) ⇒ RackMiddleware
constructor
Creates a new Rack-based middleware for serving YARD documentation.
Constructor Details
#initialize(app, opts = {}) ⇒ RackMiddleware
Creates a new Rack-based middleware for serving YARD documentation.
27 28 29 30 31 |
# File 'lib/yard/server/rack_adapter.rb', line 27 def initialize(app, opts = {}) args = [opts[:libraries] || {}, opts[:options] || {}, opts[:server_options] || {}] @app = app @adapter = RackAdapter.new(*args) end |
Instance Method Details
#call(env) ⇒ Object
33 34 35 36 37 38 39 40 |
# File 'lib/yard/server/rack_adapter.rb', line 33 def call(env) status, headers, body = *@adapter.call(env) if status == 404 @app.call(env) else [status, headers, body] end end |