Skip to content
Myr

adjust the routergroup Any method (#2701)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by heige · committed by GitHub · parent 2d3d6d2 · Browse files · 1 file+11 added−9 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+11 added−9 removed

  • other:+11 added−9 removed

1 file+11 added−9 removed

modified:routergroup.go+11 added-9 removed
12 unmodified lines
1314var (15 // reg match english letters for http method name16 regEnLetter = regexp.MustCompile("^[A-Z]+$")1718 // anyMethods for RouterGroup Any method19 anyMethods = []string{20 http.MethodGet, http.MethodPost, http.MethodPut, http.MethodPatch,21 http.MethodHead, http.MethodOptions, http.MethodDelete, http.MethodConnect,22 http.MethodTrace,23 }24)2526// IRouter defines all router handle interface includes single and group router.27type IRouter interface {
114 unmodified lines
142143// Any registers a route that matches all the HTTP methods.144// GET, POST, PUT, PATCH, HEAD, OPTIONS, DELETE, CONNECT, TRACE.145func (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 }149150 return group.returnObj()151}152153// StaticFile registers a single route in order to serve a single file of the local filesystem.
82 unmodified lines