Class: Committee::Middleware::Base
- Inherits:
-
Object
- Object
- Committee::Middleware::Base
show all
- Defined in:
- lib/committee/middleware/base.rb
Instance Method Summary
collapse
Constructor Details
#initialize(app, options = {}) ⇒ Base
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
# File 'lib/committee/middleware/base.rb', line 3
def initialize(app, options={})
@app = app
@error_class = options.fetch(:error_class, Committee::ValidationError)
@params_key = options[:params_key] || "committee.params"
= options[:headers_key] || "committee.headers"
@raise = options[:raise]
@schema = get_schema(options[:schema] ||
raise(ArgumentError, "Committee: need option `schema`"))
@router = Committee::Router.new(@schema,
prefix: options[:prefix]
)
end
|
Instance Method Details
#call(env) ⇒ Object
18
19
20
21
22
23
24
25
26
|
# File 'lib/committee/middleware/base.rb', line 18
def call(env)
request = Rack::Request.new(env)
if @router.includes_request?(request)
handle(request)
else
@app.call(request.env)
end
end
|