Closed coderanger closed 3 years ago
@coderanger Please sign the Contributor License Agreement!
Click here to manually synchronize the status of this Pull Request.
See the FAQ for frequently asked questions.
@coderanger Thank you for signing the Contributor License Agreement!
@essen is there are more typical way of returning a 500 response in modern Cowboy?
It's a response like any other so cowboy_req:reply
is the way to go.
Is the way I'm calling it correct? Most of the examples were a lot simpler so I wasn't entirely certain if I plugged it all together correctly :)
Assuming Response
is the response body yes. Sorry I'm not available to check further at the moment.
To reproduce a failure, use a very low timeout:
curl -v -H "Accept:application/json" -H "timeout: 1" -u guest:guest "http://localhost:15672/api/healthchecks/node"
which will return
< HTTP/1.1 500 Internal Server Error
< cache-control: no-cache
< content-length: 38
< content-security-policy: script-src 'self' 'unsafe-eval' 'unsafe-inline'; object-src 'self'
< content-type: application/json
< date: Wed, 09 Sep 2020 12:19:22 GMT
< server: Cowboy
< vary: accept, accept-encoding, origin
{
"status": "failed",
"reason": "timeout"
}
Thank you!
Backported to v3.8.x
.
Fixes #840.
My Erlang is extremely rusty so this might be entirely the wrong way to do this, but I figured I would try.