1
0
mirror of https://github.com/labstack/echo.git synced 2025-07-15 01:34:53 +02:00

Logging middleware fixes

Signed-off-by: Vishal Rana <vr@labstack.com>
This commit is contained in:
Vishal Rana
2016-03-21 17:27:14 -07:00
parent 703174e58f
commit a66162a3d2
16 changed files with 153 additions and 155 deletions

View File

@ -65,7 +65,7 @@ func NewConfig(c *engine.Config) (s *Server) {
},
},
},
handler: engine.HandlerFunc(func(req engine.Request, res engine.Response) {
handler: engine.HandlerFunc(func(rq engine.Request, rs engine.Response) {
s.logger.Fatal("handler not set")
}),
logger: log.New("echo"),
@ -95,24 +95,24 @@ func (s *Server) Start() {
func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
// Request
req := s.pool.request.Get().(*Request)
rq := s.pool.request.Get().(*Request)
reqHdr := s.pool.header.Get().(*Header)
reqURL := s.pool.url.Get().(*URL)
reqHdr.reset(r.Header)
reqURL.reset(r.URL)
req.reset(r, reqHdr, reqURL)
rq.reset(r, reqHdr, reqURL)
// Response
res := s.pool.response.Get().(*Response)
rs := s.pool.response.Get().(*Response)
resHdr := s.pool.header.Get().(*Header)
resHdr.reset(w.Header())
res.reset(w, resHdr)
rs.reset(w, resHdr)
s.handler.ServeHTTP(req, res)
s.handler.ServeHTTP(rq, rs)
s.pool.request.Put(req)
s.pool.request.Put(rq)
s.pool.header.Put(reqHdr)
s.pool.url.Put(reqURL)
s.pool.response.Put(res)
s.pool.response.Put(rs)
s.pool.header.Put(resHdr)
}