Accept pretty
parameter for pretty formatting
If the parameter is equal to `true` (in any case--`TRUE`, `True`) or a positive integer, return pretty formatted JSON data. No tests are necessary.
This commit is contained in:
parent
da62a6ce3c
commit
0e406b3ed1
|
@ -10,7 +10,13 @@ class Travis::Api::App
|
|||
|
||||
def respond_with(resource, options = {})
|
||||
result = respond(resource, options)
|
||||
result = JSON.pretty_generate(result) if result && response.content_type =~ /application\/json/
|
||||
if result && response.content_type =~ /application\/json/
|
||||
if params[:pretty].downcase == 'true' || params[:pretty].to_i > 0
|
||||
JSON.pretty_generate(result)
|
||||
else
|
||||
result.to_json
|
||||
end
|
||||
end
|
||||
halt result || 404
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user