func (server *app) ServeHTTP(w http.ResponseWriter, r *http.Request) { var c = context.NewContext(w, r) var h handler.HandlerInterface if r, ok := server.routerMap[r.URL.Path]; ok { h, ok = r.Match(c) } else { for _, r := range server.routers { if h, ok = r.Match(c); ok { break } } } if h != nil { b := h if ParseBody { c.ParseBody() } defer b.OnFinally(c) b.OnBefore(c) switch c.Request.Method { case GET: b.Get(c) case POST: b.Post(c) case PUT: b.Put(c) case DELETE: b.Delete(c) case HEAD: b.Head(c) case OPTIONS: b.Options(c) default: b.NotFound(c) } b.OnAfter(c) } else { if server.NotFound != nil { server.NotFound(c) } } }