Object
@param [Rack Application] app The standard argument for a Rack middleware. @param [Hash] options A hash of options, simply stored for use by subclasses.
# File lib/grape/middleware/base.rb, line 8 def initialize(app, options = {}) @app = app @options = default_options.merge(options) end
@abstract Called after the application is called in the middleware lifecycle. @return [Response, nil] a Rack SPEC response or nil to call the application afterwards.
# File lib/grape/middleware/base.rb, line 36 def after end
@abstract Called before the application is called in the middleware lifecycle.
# File lib/grape/middleware/base.rb, line 30 def before end
# File lib/grape/middleware/base.rb, line 17 def call(env) dup.call!(env) end
# File lib/grape/middleware/base.rb, line 21 def call!(env) @env = env before @app_response = @app.call(@env) after || @app_response end
# File lib/grape/middleware/base.rb, line 51 def content_type content_type_for(env['api.format'] || options[:format]) || 'text/html' end
# File lib/grape/middleware/base.rb, line 43 def content_type_for(format) HashWithIndifferentAccess.new(content_types)[format] end
# File lib/grape/middleware/base.rb, line 47 def content_types ContentTypes.content_types_for(options[:content_types]) end
# File lib/grape/middleware/base.rb, line 13 def default_options {} end
Generated with the Darkfish Rdoc Generator 2.