chainhook
chainhook copied to clipboard
Return proper http status codes for rocket servers
Currently, for the rocket servers we implement, all requests that make it to the actual request handler respond with 200 OK
event if the status
field of our response is not 200. We're always returning something like:
return Json(json!({
"status": 422,
"error": e.to_string(),
}))
but I think there should be a different way to respond which actually uses the status code we set.
Good observation! Any particular reason we are explicitly handling/returning custom code versus relying on the Rocket framework itself to produce the respective status codes? I briefly looked at: https://rocket.rs/v0.5-rc/guide/responses/#status — the opening paragraph also made me wonder if we intend explicit handling.
I also noticed that Rocket's latest release is at an RC state, and not yet a major (production-ready) release. Is it Okay to rely on a pre-production dependency for our Chainhook v1.0? I guess RC status is sufficient enough, but I wanted to run it by the experts—just extra due diligence.
Any particular reason we are explicitly handling/returning custom code versus relying on the Rocket framework itself to produce the respective status codes?
I don't know if there was an original reason for this, but I will look into that when this issue is worked!
Is it Okay to rely on a pre-production dependency for our Chainhook v1.0? I feel confident that rocket is stable despite the RC state. See these notes in their FAQ: https://rocket.rs/v0.5-rc/guide/faq/#in-prod