Class: Grape::Middleware::Formatter
- Inherits:
-
Base
- Object
- Base
- Grape::Middleware::Formatter
show all
- Defined in:
- lib/grape/middleware/formatter.rb
Constant Summary
collapse
- CHUNKED =
'chunked'
- FORMAT =
'format'
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, #initialize, #mime_types, #response
#header
Methods included from Helpers
#context
Instance Method Details
#after ⇒ Object
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/grape/middleware/formatter.rb', line 22
def after
return unless @app_response
status, , bodies = *@app_response
if Rack::Utils::STATUS_WITH_NO_ENTITY_BODY.include?(status)
[status, , []]
else
build_formatted_response(status, , bodies)
end
end
|
#before ⇒ Object
17
18
19
20
|
# File 'lib/grape/middleware/formatter.rb', line 17
def before
negotiate_content_type
read_body_input
end
|
#default_options ⇒ Object
9
10
11
12
13
14
15
|
# File 'lib/grape/middleware/formatter.rb', line 9
def default_options
{
default_format: :txt,
formatters: {},
parsers: {}
}
end
|