Custom 404 Not Found handler #3

Open
opened 2025-07-19 18:36:14 +00:00 by vickodev · 2 comments
Contributor

Sometimes in some web servers we have a custom response for Not Found (404), talking about Content-Type and message.
I saw that server has a default empty response, can there be a way to handle a customized response?

I realized that because of the condition of how the server handles the request handler, this needs to be passed via the constructor, but let me know your appreciation about it, it's posible?

Sometimes in some web servers we have a custom response for Not Found (404), talking about Content-Type and message. I saw that server has a default empty response, can there be a way to handle a customized response? I realized that because of the condition of how the server handles the request handler, this needs to be passed via the constructor, but let me know your appreciation about it, it's posible?
Owner

Hmm. I wonder, is there any use-case that would not be covered by the following?

s.Get("/*", myNotFoundHandler)
Hmm. I wonder, is there any use-case that would not be covered by the following? ```go s.Get("/*", myNotFoundHandler) ```
ed changed title from Custom Not Found (404) http reponse. to Custom 404 Not Found handler 2025-07-19 19:51:39 +00:00
Author
Contributor

Yes man, that could work, but wouldn't that imply having to add all possible HTTP verbs?
I know it's not difficult, but it could be complex knowing that the server already has something to avoid all that configuration.
If you have a good different solution, let me know that.

Yes man, that could work, but wouldn't that imply having to add all possible HTTP verbs? I know it's not difficult, but it could be complex knowing that the server already has something to avoid all that configuration. If you have a good different solution, let me know that.
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: go/web#3
No description provided.