Skip to content

Commit

Permalink
Update ch5-03-middleware.md
Browse files Browse the repository at this point in the history
修复5.3.3 示例代码
nil map panic: assignment to entry in nil map
  • Loading branch information
vgopher authored Apr 8, 2021
1 parent d55969d commit 0c87b96
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions ch5-web/ch5-03-middleware.md
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 0c87b96

Please sign in to comment.