serveHTTP implements `http.Handler` interface, which serves HTTP requests.
(w http.ResponseWriter, r *http.Request)
| 769 | |
| 770 | // serveHTTP implements `http.Handler` interface, which serves HTTP requests. |
| 771 | func (e *Echo) serveHTTP(w http.ResponseWriter, r *http.Request) { |
| 772 | c := e.contextPool.Get().(*Context) |
| 773 | defer e.contextPool.Put(c) |
| 774 | |
| 775 | c.Reset(r, w) |
| 776 | |
| 777 | // The global (e.chain) and pre-middleware (e.preChain) chains are compiled once in buildRouterChains and |
| 778 | // reused here, so no middleware closures are allocated per request. |
| 779 | var err error |
| 780 | if e.premiddleware == nil { |
| 781 | c.handler = e.router.Route(c) |
| 782 | err = e.chain(c) |
| 783 | } else { |
| 784 | err = e.preChain(c) |
| 785 | } |
| 786 | |
| 787 | if err != nil { |
| 788 | e.HTTPErrorHandler(c, err) |
| 789 | } |
| 790 | } |
| 791 | |
| 792 | // Start stars HTTP server on given address with Echo as a handler serving requests. The server can be shutdown by |
| 793 | // sending os.Interrupt signal with `ctrl+c`. Method returns only errors that are not http.ErrServerClosed. |
no test coverage detected