From b00d3ec5b6100fd514208c6c4a3547c293fde079 Mon Sep 17 00:00:00 2001 From: hansongyu <359859461@qq.com> Date: Wed, 13 Jul 2022 09:34:11 +0800 Subject: [PATCH] Update routergroup.go --- routergroup.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/routergroup.go b/routergroup.go index 3c082d93..e1728cc7 100644 --- a/routergroup.go +++ b/routergroup.go @@ -141,6 +141,14 @@ func (group *RouterGroup) HEAD(relativePath string, handlers ...HandlerFunc) IRo return group.handle(http.MethodHead, relativePath, handlers) } +// Customize almost same with router.Handle but no HTTP method limited. +func (group *RouterGroup) Customize(method string,relativePath string, handlers ...HandlerFunc) IRoutes { + matched,err := regexp.MatchString("^[A-Za-z]+$",method) + assert1(matched == true, "HTTP method can only be letters") + assert1(err == nil, "HTTP method is wrong") + return group.handle(method, relativePath, handlers) +} + // Any registers a route that matches all the HTTP methods. // GET, POST, PUT, PATCH, HEAD, OPTIONS, DELETE, CONNECT, TRACE. func (group *RouterGroup) Any(relativePath string, handlers ...HandlerFunc) IRoutes {