@@ -107,9 +107,8 @@ func (mx *Mux) Use(middlewares ...func(http.Handler) http.Handler) {
107107// Handle adds the route `pattern` that matches any http method to
108108// execute the `handler` http.Handler.
109109func (mx * Mux ) Handle (pattern string , handler http.Handler ) {
110- parts := strings .SplitN (pattern , " " , 2 )
111- if len (parts ) == 2 {
112- mx .Method (parts [0 ], parts [1 ], handler )
110+ if method , rest , found := strings .Cut (pattern , " " ); found {
111+ mx .Method (method , rest , handler )
113112 return
114113 }
115114
@@ -119,9 +118,8 @@ func (mx *Mux) Handle(pattern string, handler http.Handler) {
119118// HandleFunc adds the route `pattern` that matches any http method to
120119// execute the `handlerFn` http.HandlerFunc.
121120func (mx * Mux ) HandleFunc (pattern string , handlerFn http.HandlerFunc ) {
122- parts := strings .SplitN (pattern , " " , 2 )
123- if len (parts ) == 2 {
124- mx .Method (parts [0 ], parts [1 ], handlerFn )
121+ if method , rest , found := strings .Cut (pattern , " " ); found {
122+ mx .Method (method , rest , handlerFn )
125123 return
126124 }
127125
0 commit comments