hirosystems / chainhook

Extract transactions from Stacks and Bitcoin and build event driven re-org resistant indexers and databases.
GNU General Public License v3.0
143 stars 57 forks source link

Return proper http status codes for rocket servers #327

Open MicaiahReid opened 1 year ago

MicaiahReid commented 1 year ago

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.

sabbyanandan commented 1 year ago

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.

sabbyanandan commented 1 year ago

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.

MicaiahReid commented 1 year ago

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