ironsmile / nedomi

Highly performant HTTP reverse proxy with efficient caching of big files
GNU General Public License v3.0
81 stars 9 forks source link

Source of HTTP error messages (eg. "404 page not found") #228

Closed alectrocute closed 4 years ago

alectrocute commented 5 years ago

Hey @ironsmile,

I'm going to be annoying, I already feel bad.

I've combed through this code for hours and couldn't find where the error messages are originating from, eg. "404 page not found". I've looked through the dependencies as well to no avail.

If I'd like to change the error message to a custom one, such as setting http.NotFound to say "This page isn't available", etc. where would I go about doing that?

Thanks so much!

ironsmile commented 5 years ago

Hello @alectrocute ! This probably comes from the NotFound handler in the standard http library. Here is its source where the message is sent.

As far as I can tell you are using the dir handler which itself uses http.FileServer.

Being able to change the "not found" page would be great. Or any other error page, similar to the error_page directive in nginx. I don't think we have this feature in nedomi at this moment. You can modify the dir handler or alternatively write a new handler which supports internal redirects for error pages. There is this guide for writing new handlers.