Skip to content

Commit

Permalink
Add a warning to HandleFunc about the panic
Browse files Browse the repository at this point in the history
  • Loading branch information
HRogge committed Oct 18, 2023
1 parent f3f608e commit 5e22af2
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions mux/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit 5e22af2

Please sign in to comment.