module Grape::DSL::Callbacks::ClassMethods
Public Instance Methods
Source
# File lib/grape/dsl/callbacks.rb, line 43 def after(&block) namespace_stackable(:afters, block) end
Execute the given block after the endpoint code has run.
Source
# File lib/grape/dsl/callbacks.rb, line 38 def after_validation(&block) namespace_stackable(:after_validations, block) end
Execute the given block after validations and coercions, but before any endpoint code.
Source
# File lib/grape/dsl/callbacks.rb, line 26 def before(&block) namespace_stackable(:befores, block) end
Execute the given block before validation, coercion, or any endpoint code is executed.
Source
# File lib/grape/dsl/callbacks.rb, line 32 def before_validation(&block) namespace_stackable(:before_validations, block) end
Execute the given block after ‘before`, but prior to validation or coercion.
Source
# File lib/grape/dsl/callbacks.rb, line 63 def finally(&block) namespace_stackable(:finallies, block) end
Allows you to specify a something that will always be executed after a call API
call. Unlike the ‘after` block, this code will run even on unsuccesful requests. @example
class ExampleAPI < Grape::API before do ApiLogger.start end finally do ApiLogger.close end end
This will make sure that the ApiLogger is opened and closed around every request @param ensured_block [Proc] The block to be executed after every api_call