Sha256: 37cd164e6345bc53c3481e5113748753e9ac49d0fce3725867bae4f7162071dd

Contents?: true

Size: 471 Bytes

Versions: 22

Compression:

Stored size: 471 Bytes

Contents

module Grape
  module Middleware
    # 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 }
    class Filter < Base
      def before
        app.instance_eval(&options[:before]) if options[:before]
      end

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

Version data entries

22 entries across 22 versions & 2 rubygems

Version Path
grape-extra_validators-2.0.0 vendor/bundle/ruby/2.6.0/gems/grape-1.2.5/lib/grape/middleware/filter.rb
grape-extra_validators-1.0.0 vendor/bundle/ruby/2.4.0/gems/grape-1.2.5/lib/grape/middleware/filter.rb
grape-1.2.5 lib/grape/middleware/filter.rb
grape-1.2.4 lib/grape/middleware/filter.rb
grape-1.2.3 lib/grape/middleware/filter.rb
grape-1.2.2 lib/grape/middleware/filter.rb
grape-1.2.1 lib/grape/middleware/filter.rb
grape-1.2.0 lib/grape/middleware/filter.rb
grape-1.1.0 lib/grape/middleware/filter.rb
grape-1.0.3 lib/grape/middleware/filter.rb
grape-1.0.2 lib/grape/middleware/filter.rb
grape-1.0.1 lib/grape/middleware/filter.rb
grape-1.0.0 lib/grape/middleware/filter.rb
grape-0.19.2 lib/grape/middleware/filter.rb
grape-0.19.1 lib/grape/middleware/filter.rb
grape-0.19.0 lib/grape/middleware/filter.rb
grape-0.18.0 lib/grape/middleware/filter.rb
grape-0.17.0 lib/grape/middleware/filter.rb
grape-0.16.2 lib/grape/middleware/filter.rb
grape-0.16.1 lib/grape/middleware/filter.rb