From 726cda113ae5f845ba82bc75c46d5c8790346d38 Mon Sep 17 00:00:00 2001 From: Umputun Date: Fri, 10 Jan 2025 12:15:34 -0600 Subject: [PATCH] fix notfound func docs typo #14 docs formatting issue Update README.md --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 0350123..375e9dd 100644 --- a/README.md +++ b/README.md @@ -132,9 +132,9 @@ group.Route(func(b *routegroup.Bundle) { It is possible to set a custom `NotFoundHandler` for the group. This handler will be called when no other route matches the request: ```go - group.NotFoundHandler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - http.Error(w, "404 page not found, something is wrong!", http.StatusNotFound) - }) +group.NotFoundHandler(func(w http.ResponseWriter, _ *http.Request) { + http.Error(w, "404 page not found, something is wrong!", http.StatusNotFound) +} ``` If a custom `NotFoundHandler` is not configured, `routegroup` will default to using a handler from the standard library (`http.NotFoundHandler()`). It is important to note that the `NotFoundHandler` serves as a catch-all route, which influences "Method Not Allowed" (405) responses. Consequently, if an incorrect method is called, the response will be 404 (or the custom status specified by the `NotFoundHandler`) rather than 405. This behavior aligns with the standard `http.ServeMux` and [may be improved](https://github.com/golang/go/issues/65648) in future versions of Go.