-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Open
Labels
Description
I have a post endpoint where I'd like to conditionally return a custom Rack::Response, like so:
post do
if some_condition?
hash_of_contextually_relevant_goodness = { foo: 'bar' }
Rack::Response.new(
[hash_of_contextually_relevant_goodness],
418,
{ 'Content-Type' => 'application/json' }
).finish
else
# do some object creation stuff
end
endHowever, this returns the following response body:
[
418,
{
"Content-Length": "13",
"Content-Type": "application/json"
},
{
"block": {},
"body": {
"block": null,
"body": [
"{:foo=>\"bar\"}"
],
"chunked": false,
"header": {
"Content-Length": "13",
"Content-Type": "application/json"
},
"length": 13,
"status": 418,
"writer": {}
},
"closed": false
}
]It looks like the response is doubling up. What is the correct way to return a custom Rack::Response from my endpoint?
danillos