1
0
mirror of https://github.com/chai2010/advanced-go-programming-book.git synced 2025-05-23 20:02:22 +00:00

Update ch5-03-middleware.md

修复5.3.3 示例代码
nil map panic: assignment to entry in nil map
This commit is contained in:
vgopher 2021-04-08 08:53:24 +08:00 committed by GitHub
parent d55969d945
commit 0c87b968aa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -233,8 +233,10 @@ type Router struct {
mux map[string] http.Handler
}
func NewRouter() *Router{
return &Router{}
func NewRouter() *Router {
return &Router{
mux: make(map[string]http.Handler),
}
}
func (r *Router) Use(m middleware) {