From 5e22af2ae51201e23e85d8ed470331db45a95c88 Mon Sep 17 00:00:00 2001 From: Henning Rogge Date: Wed, 18 Oct 2023 09:33:48 +0200 Subject: [PATCH] Add a warning to HandleFunc about the panic --- mux/router.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mux/router.go b/mux/router.go index e3d19986..fc19b875 100644 --- a/mux/router.go +++ b/mux/router.go @@ -155,6 +155,8 @@ func (r *Router) DefaultHandle(handler Handler) { } // HandleFunc adds a handler function to the Router for pattern. +// This function will panic if the pattern parameter is invalid. If the APP provides 'user defined patterns' better +// use Handle(), which will return an error. func (r *Router) HandleFunc(pattern string, handler func(w ResponseWriter, r *Message)) { if err := r.Handle(pattern, HandlerFunc(handler)); err != nil { panic(fmt.Errorf("cannot handle pattern(%v): %w", pattern, err))