Repository Details
Shared by
HelloGitHub Rating
0 ratings
一个基于 Golang 语言的 HTTP 路由库
Past 6 days Received -2 stars ✨
Use arrow keys to explore dates, Home and End for the first and last date, Escape to dismiss.| Date | Star | Daily change |
|---|---|---|
| 周日 | 21,832 | — |
| 周一 | 21,833 | +1 |
| 周二 | 21,833 | 0 |
| 周三 | 21,832 | -1 |
| 周四 | 21,832 | 0 |
| 周五 | 21,830 | -2 |
21.8k
Stars
No
Chinese
Go
Language
No
Active
118
Contributors
48
Issues
Yes
Organization
None
Latest
2k
Forks
BSD-3-Clause
License
一个基于 Golang 语言的 HTTP 路由库。由于支持各种正则匹配路由,使得对应处理函数复用率大大提高。相比于 Gin、beego 等框架,这个项目基本上跟标准库的 `http.ServeMux` 和 `mux.Router` 保持一致,比标准库更强大的是它支持的正则匹配路由、自定义保留字段、嵌套路由等功能。示例代码:
```go
func main() {
r := mux.NewRouter()
r.HandleFunc("/", HomeHandler)
r.HandleFunc("/products", ProductsHandler)
r.HandleFunc("/articles", ArticlesHandler)
http.Handle("/", r)
}
r := mux.NewRouter()
r.HandleFunc("/products/{key}", ProductHandler)
r.HandleFunc("/articles/{category}/", ArticlesCategoryHandler)
r.HandleFunc("/articles/{category}/{id:[0-9]+}", ArticleHandler)
```
Included in:
Vol.40
Comments
Rating:
No comments yet