7
8
9
10
11
12
13
14
15
16
17
18
19
|
# File 'lib/tentd/api/router/serialize_response.rb', line 7
def call(env)
response = if env.response
env.response.kind_of?(String) ? env.response : env.response.to_json(serialization_options(env))
end
status = env['response.status'] || (response ? 200 : 404)
= if env['response.type'] || status == 200 && response && !response.empty?
{ 'Content-Type' => env['response.type'] || MEDIA_TYPE }
else
{}
end
.merge!('Access-Control-Allow-Origin' => '*') if env['HTTP_ORIGIN']
[status, , [response.to_s]]
end
|