issue9 / mux Goto Github PK
View Code? Open in Web Editor NEW适用第三方框架实现可定制的路由
Home Page: https://pkg.go.dev/github.com/issue9/mux/v8
License: MIT License
适用第三方框架实现可定制的路由
Home Page: https://pkg.go.dev/github.com/issue9/mux/v8
License: MIT License
多数情况下,让人无法判断到底是哪个handler处理相关的请求
m := mux.NewServeMux()
m.Get("/abcdefg", h)
p := m.Prefix("/abc")
p.Get("def", h)
p.Get("cfg", h)
p.Clean() // 此处会把 m.Get("/abcdefg", h) 也一并删除
比如:
/posts/{id1:\\d+}.html
/posts/{id2:\\d+}.html
这类仅参数名称不同,但是正则相同的路由,第二第加入的是始终无法路由到的。在添加时应该做一些检测。
Method包含了普通的Add()
和AddFun()
方法,及与之对应的Must*()
方法,
Must*()
系列方法在碰到错误时,直接panic,而不像其它方法一样返回错误信息。
是否可以将Must*()
系列方法独立出来:
type ErrorMethod struct {
m *Method
errs []error
}
fumc (m *ErrorMehtod) Add(pattern string, h http.Handler, methods ...string) *ErrorMehtod {
err := m.m.Add(pattern, h, methods...)
if err != nil {
m.errs = append(m.errs,err)
}
return m
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.