Class: Rack::Spec::Docs
- Inherits:
-
Object
- Object
- Rack::Spec::Docs
- Defined in:
- lib/rack/spec/docs.rb
Constant Summary collapse
- DEFAULT_PATH =
"/docs"
Instance Method Summary collapse
-
#call(env) ⇒ Object
Returns rendered document for document request.
-
#initialize(app, path: nil, schema: nil) ⇒ Docs
constructor
Behaves as a rack-middleware.
Constructor Details
#initialize(app, path: nil, schema: nil) ⇒ Docs
Behaves as a rack-middleware
10 11 12 13 14 |
# File 'lib/rack/spec/docs.rb', line 10 def initialize(app, path: nil, schema: nil) @app = app @path = path @document = Jdoc::Generator.call(schema) end |
Instance Method Details
#call(env) ⇒ Object
Returns rendered document for document request
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/rack/spec/docs.rb', line 18 def call(env) if env["REQUEST_METHOD"] == "GET" && env["PATH_INFO"] == path [ 200, { "Content-Type" => "text/plain; charset=utf-8" }, [@document], ] else @app.call(env) end end |