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

Constructor Details

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

Instance Method Details

#afterObject


12
13
14
# File 'lib/grape/middleware/filter.rb', line 12

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

#beforeObject


8
9
10
# File 'lib/grape/middleware/filter.rb', line 8

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