@@ -14,6 +14,13 @@ import (
1414var (
1515 // reg match english letters for http method name
1616 regEnLetter = regexp .MustCompile ("^[A-Z]+$" )
17+
18+ // anyMethods for RouterGroup Any method
19+ anyMethods = []string {
20+ http .MethodGet , http .MethodPost , http .MethodPut , http .MethodPatch ,
21+ http .MethodHead , http .MethodOptions , http .MethodDelete , http .MethodConnect ,
22+ http .MethodTrace ,
23+ }
1724)
1825
1926// IRouter defines all router handle interface includes single and group router.
@@ -136,15 +143,10 @@ func (group *RouterGroup) HEAD(relativePath string, handlers ...HandlerFunc) IRo
136143// Any registers a route that matches all the HTTP methods.
137144// GET, POST, PUT, PATCH, HEAD, OPTIONS, DELETE, CONNECT, TRACE.
138145func (group * RouterGroup ) Any (relativePath string , handlers ... HandlerFunc ) IRoutes {
139- group .handle (http .MethodGet , relativePath , handlers )
140- group .handle (http .MethodPost , relativePath , handlers )
141- group .handle (http .MethodPut , relativePath , handlers )
142- group .handle (http .MethodPatch , relativePath , handlers )
143- group .handle (http .MethodHead , relativePath , handlers )
144- group .handle (http .MethodOptions , relativePath , handlers )
145- group .handle (http .MethodDelete , relativePath , handlers )
146- group .handle (http .MethodConnect , relativePath , handlers )
147- group .handle (http .MethodTrace , relativePath , handlers )
146+ for _ , method := range anyMethods {
147+ group .handle (method , relativePath , handlers )
148+ }
149+
148150 return group .returnObj ()
149151}
150152
0 commit comments