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)
- - (Object) call(env)
-
- (RackMiddleware) initialize(app, opts = {})
constructor
Creates a new Rack-based middleware for serving YARD documentation.
Constructor Details
- (RackMiddleware) initialize(app, opts = {})
Creates a new Rack-based middleware for serving YARD documentation.
26 27 28 29 30 |
# File 'lib/yard/server/rack_adapter.rb', line 26 def initialize(app, opts = {}) args = [opts[:libraries] || {}, opts[:options] || {}, opts[:server_options] || {}] @app = app @adapter = RackAdapter.new(*args) end |
Instance Method Details
- (Object) call(env)
32 33 34 35 36 37 38 39 |
# File 'lib/yard/server/rack_adapter.rb', line 32 def call(env) status, headers, body = *@adapter.call(env) if status == 404 @app.call(env) else [status, headers, body] end end |