Crow icon indicating copy to clipboard operation
Crow copied to clipboard

Custom response code

Open hongju91 opened this issue 3 years ago • 2 comments

How can I use a custom response code that's not set in default crow, like 1001? now 500 will be responsed for all other custom codes.

Thank you!

hongju91 avatar Nov 01 '22 09:11 hongju91

Currently, Crow doesn't support custom status codes. if it is to be implemented, it should not be by simply using crow::response(1001).

The-EDev avatar Nov 01 '22 09:11 The-EDev

I ran into a similar issue while integrating with another library. The library's return codes had overlap with standard status codes. In this case, I standardized my response body to include the required information. Here's an example of the response body:

{
  "code": 200,
  "type": "invalid module number",
  "message": "module slot not found"
}

I don't know much about your specific implementation; so your mileage may vary.

xia-stan avatar Mar 03 '23 13:03 xia-stan

You can use your own http response codes as described above. Including the code and additional error responses into the response body is not supported by the library as it is not part of http standard.

gittiver avatar May 29 '24 11:05 gittiver