2,190
社区成员
发帖
与我相关
我的任务
分享
func newRoute(method string, pattern string, handlers []Handler) route {
route := route{method, nil, handlers}
r := regexp.MustCompile(`:[^/#?()\.\\]+`)
pattern = r.ReplaceAllStringFunc(pattern, func(m string) string {
return fmt.Sprintf(`(?P<%s>[^/#?]+)`, m[1:len(m)])
})
pattern += `\/?`
route.regex = regexp.MustCompile(pattern)
return route
}
r := regexp.MustCompile(`:[^/#?()\.\\]+`)
感觉可以写成
r := regexp.MustCompile(`:[^/#?().\\]+`)
pattern += `\/?`
可以写成
pattern += `/?`
不知道正确不正确