87e8bcc9 by MrLee.Kun

fix FilterHandler crash issue

Filter Handler will crash with error assignment to entry in nil map , params from function Tree.Match() maybe nil.
1 parent 31e5edbd
...@@ -616,6 +616,9 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request) ...@@ -616,6 +616,9 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request)
616 } 616 }
617 if ok, params := filterR.ValidRouter(urlPath); ok { 617 if ok, params := filterR.ValidRouter(urlPath); ok {
618 for k, v := range params { 618 for k, v := range params {
619 if context.Input.Params == nil {
620 context.Input.Params = make(map[string]string)
621 }
619 context.Input.Params[k] = v 622 context.Input.Params[k] = v
620 } 623 }
621 filterR.filterFunc(context) 624 filterR.filterFunc(context)
...@@ -699,9 +702,11 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request) ...@@ -699,9 +702,11 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request)
699 p[strconv.Itoa(k)] = v 702 p[strconv.Itoa(k)] = v
700 } 703 }
701 } 704 }
705 if p != nil {
702 context.Input.Params = p 706 context.Input.Params = p
703 } 707 }
704 } 708 }
709 }
705 710
706 } 711 }
707 712
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!