module Grape::DSL::Middleware::ClassMethods
Public Instance Methods
middleware()
click to toggle source
Retrieve an array of the middleware classes and arguments that are currently applied to the application.
# File lib/grape/dsl/middleware.rb, line 27 def middleware namespace_stackable(:middleware) || [] end
use(middleware_class, *args, &block)
click to toggle source
Apply a custom middleware to the API. Applies to the current namespace and any children, but not parents.
@param middleware_class [Class] The class of the middleware you'd like
to inject.
# File lib/grape/dsl/middleware.rb, line 17 def use(middleware_class, *args, &block) arr = [middleware_class, *args] arr << block if block_given? namespace_stackable(:middleware, arr) end