Module: Grape::DSL::Middleware
- Included in:
- API::Instance
- Defined in:
- lib/grape/dsl/middleware.rb
Instance Method Summary collapse
-
#middleware ⇒ Object
Retrieve an array of the middleware classes and arguments that are currently applied to the application.
-
#use(middleware_class, *args, &block) ⇒ Object
Apply a custom middleware to the API.
Instance Method Details
#middleware ⇒ Object
Retrieve an array of the middleware classes and arguments that are currently applied to the application.
31 32 33 |
# File 'lib/grape/dsl/middleware.rb', line 31 def middleware inheritable_setting.namespace_stackable[:middleware] || [] end |
#use(middleware_class, *args, &block) ⇒ Object
Apply a custom middleware to the API. Applies to the current namespace and any children, but not parents.
12 13 14 15 16 17 |
# File 'lib/grape/dsl/middleware.rb', line 12 def use(middleware_class, *args, &block) arr = [:use, middleware_class, *args] arr << block if block inheritable_setting.namespace_stackable[:middleware] = arr end |