Class: Grape::Middleware::Filter

Inherits:
Base
  • Object
show all
Defined in:
lib/grape/middleware/filter.rb

Overview

This is a simple middleware for adding before and after filters to Grape APIs. It is used like so:

use Grape::Middleware::Filter, before: -> { do_something }, after: -> { do_something }

Constant Summary

Constants inherited from Base

Base::TEXT_HTML

Instance Attribute Summary

Attributes inherited from Base

#app, #env, #options

Instance Method Summary collapse

Methods inherited from Base

#call, #call!, #content_type, #content_type_for, #content_types, #default_options, #initialize, #mime_types, #response

Methods included from DSL::Headers

#header

Methods included from Helpers

#context

Constructor Details

This class inherits a constructor from Grape::Middleware::Base

Instance Method Details

#afterObject



14
15
16
# File 'lib/grape/middleware/filter.rb', line 14

def after
  app.instance_eval(&options[:after]) if options[:after]
end

#beforeObject



10
11
12
# File 'lib/grape/middleware/filter.rb', line 10

def before
  app.instance_eval(&options[:before]) if options[:before]
end