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: lambda { do_something }, after: lambda { do_something }

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

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