1
0
mirror of https://github.com/labstack/echo.git synced 2025-12-13 23:35:43 +02:00

Wrapper for handler in engine

Signed-off-by: Vishal Rana <vr@labstack.com>
This commit is contained in:
Vishal Rana
2016-03-06 11:38:52 -08:00
parent e1d789ecbb
commit af4c525be1
2 changed files with 21 additions and 0 deletions

View File

@@ -5,6 +5,7 @@ package fasthttp
import (
"sync"
"github.com/labstack/echo"
"github.com/labstack/echo/engine"
"github.com/labstack/gommon/log"
"github.com/valyala/fasthttp"
@@ -121,3 +122,12 @@ func (s *Server) Start() {
s.logger.Fatal(fasthttp.ListenAndServe(addr, handler))
}
}
// WrapHandler wraps `fasthttp.RequestHandler` into `echo.Handler`.
func WrapHandler(h fasthttp.RequestHandler) echo.Handler {
return echo.HandlerFunc(func(c echo.Context) error {
c := c.Request().Object().(*fasthttp.RequestCtx)
h(c)
return nil
})
}