mirror of
https://github.com/labstack/echo.git
synced 2024-11-24 08:22:21 +02:00
#407, as per @mtojek suggestion.
Signed-off-by: Vishal Rana <vr@labstack.com>
This commit is contained in:
parent
030a9a4ad1
commit
474c68d5c8
@ -19,6 +19,11 @@ type (
|
||||
writer io.Writer
|
||||
logger *log.Logger
|
||||
}
|
||||
|
||||
responseAdapter struct {
|
||||
http.ResponseWriter
|
||||
writer io.Writer
|
||||
}
|
||||
)
|
||||
|
||||
// Header implements `engine.Response#Header` method.
|
||||
@ -77,3 +82,7 @@ func (r *Response) reset(w http.ResponseWriter, h engine.Header) {
|
||||
r.committed = false
|
||||
r.writer = w
|
||||
}
|
||||
|
||||
func (r *responseAdapter) Write(b []byte) (n int, err error) {
|
||||
return r.writer.Write(b)
|
||||
}
|
||||
|
@ -129,7 +129,10 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
// WrapHandler wraps `http.Handler` into `echo.HandlerFunc`.
|
||||
func WrapHandler(h http.Handler) echo.HandlerFunc {
|
||||
return func(c echo.Context) error {
|
||||
w := c.Response().(*Response).ResponseWriter
|
||||
w := &responseAdapter{
|
||||
ResponseWriter: c.Response().(*Response).ResponseWriter,
|
||||
writer: c.Response(),
|
||||
}
|
||||
r := c.Request().(*Request).Request
|
||||
h.ServeHTTP(w, r)
|
||||
return nil
|
||||
|
Loading…
Reference in New Issue
Block a user