chiselstrike icon indicating copy to clipboard operation
chiselstrike copied to clipboard

Make 404 more developer-friendly

Open penberg opened this issue 3 years ago • 4 comments

Right now, if you access and endpoint that doesn't exist, you get 404 without any response body, which is not a very friendly developer experience (with curl in particular as nothing is printed). Let's make 404 return some "No such endpoint" text as the response text to make the experience better.

penberg avatar Apr 06 '22 11:04 penberg

shouldn't that be user-defined ?

glommer avatar Apr 06 '22 13:04 glommer

Is there a way to define a root/catch all endpoint? If there is such a way, then users can configure their default response.

athoscouto avatar Apr 06 '22 13:04 athoscouto

@glommer It can be user-defined, but there needs to be some default.

penberg avatar Apr 06 '22 14:04 penberg

There are some good ideas in https://docs.djangoproject.com/en/4.0/topics/http/middleware/ about having general methods to wrap request/response calls as well as errors. It might be nice to be able to assign these in the policy file, but generally is a good start. Some places might want to log all errors for instance, others may want to log 401s/403s. This also makes the "turn all exceptions into JSON" example from the docs into something that doesn't have to be done once per every endpoint.

mpdehaan avatar Apr 19 '22 14:04 mpdehaan