Class: Grape::Middleware::Formatter

Inherits:
Base
  • Object
show all
Extended by:
Forwardable
Includes:
PrecomputedContentTypes
Defined in:
lib/grape/middleware/formatter.rb

Defined Under Namespace

Classes: Options

Constant Summary collapse

DEFAULT_OPTIONS =
Deprecated.

Kept as a frozen Hash representation of the Options defaults for back-compat. Will be removed in a future release.

Options.new.to_h.freeze
ALL_MEDIA_TYPES =
'*/*'

Instance Attribute Summary

Attributes inherited from Base

#app, #config, #env, #options

Instance Method Summary collapse

Methods included from PrecomputedContentTypes

#content_type, #content_type_for, #content_types, #initialize, #mime_types

Methods inherited from Base

#call, #call!, #context, #initialize, #query_params, #rack_request, #response

Methods included from DSL::Headers

#header

Instance Method Details

#afterObject



30
31
32
33
34
35
36
37
38
# File 'lib/grape/middleware/formatter.rb', line 30

def after
  return unless @app_response

  status, headers, bodies = @app_response

  return [status, headers, []] if Rack::Utils::STATUS_WITH_NO_ENTITY_BODY.include?(status)

  build_formatted_response(status, headers, bodies)
end

#beforeObject



25
26
27
28
# File 'lib/grape/middleware/formatter.rb', line 25

def before
  negotiate_content_type
  read_body_input
end