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.
35 36 37 38 39 |
# File 'lib/yard/server/rack_adapter.rb', line 35 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
41 42 43 44 45 46 47 48 |
# File 'lib/yard/server/rack_adapter.rb', line 41 def call(env) status, headers, body = *@adapter.call(env) if status == 404 @app.call(env) else [status, headers, body] end end |