In v5.2.3, chi.Walk no longer visits routes with custom HTTP methods. For example:
package main
import (
"fmt"
"net/http"
"github.com/go-chi/chi/v5"
)
func main() {
r := chi.NewMux()
chi.RegisterMethod("QUACK")
r.MethodFunc("QUACK", "/quack", func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
})
chi.Walk(r, func(method string, route string, handler http.Handler, _ ...func(http.Handler) http.Handler) error {
fmt.Println(method, route)
return nil
})
}
I believe the change responsible for this is 9b9fb55, which changed method name lookup to use reverseMethodMap instead of a utility function which iterated methodMap. As far as I can tell, the problem is that reverseMethodMap is not updated by RegisterMethod, so the lookup fails and the route is not added.
In v5.2.3,
chi.Walkno longer visits routes with custom HTTP methods. For example:I believe the change responsible for this is 9b9fb55, which changed method name lookup to use
reverseMethodMapinstead of a utility function which iteratedmethodMap. As far as I can tell, the problem is thatreverseMethodMapis not updated byRegisterMethod, so the lookup fails and the route is not added.