martini 库中的路由匹配
下面这段代码摘自martini库
谁能解释下其中的正则表达式啊?
+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
+}谁能解释下其中的正则表达式啊?
...全文
相关推荐
Go-Gin是一个高性能快速的Go语言Web开发框架
Gin是一个高性能、快速的Go语言Web开发框架。它拥有类似于Martini的API,并且有更好的性能 -- 高达40倍的速度。
后端初始化 —— Go(全栈)开发企业级后台管理系统
Abstract: 终于要跟go语言沾边了,到此,作者还有点小小的兴奋呢,也不知道为啥! 不管你之前是否从事过web相关的开发,相信你一定听过【框架】这个词,不为什么,因为随着社会的发展进步,被前人总结出来的架构,经验等等,系统的、可复用的东西,我们都能认为其为框架。既然说到了框架,那么毫无疑问,我们这里要用框架了,不要问我为什么,因为时间宝贵,我们没有必要重复造轮子,当然如果你想自己写框
开源项目-gin-gonic-gin.zip
开源项目-gin-gonic-gin.zip,What's this line in the Gin source code doing
golang gin 资源包
golang gin 资源包
Golang gin中文文档
Golang gin 中文文档 架构



