File tree Expand file tree Collapse file tree 7 files changed +17
-24
lines changed Expand file tree Collapse file tree 7 files changed +17
-24
lines changed Original file line number Diff line number Diff line change @@ -55,8 +55,12 @@ type (
5555 message string
5656 }
5757
58- // Middleware interface{}
58+ Middleware interface {
59+ Process (HandlerFunc ) HandlerFunc
60+ }
61+
5962 MiddlewareFunc func (HandlerFunc ) HandlerFunc
63+
6064 // Handler interface{}
6165 HandlerFunc func (Context ) error
6266
@@ -224,6 +228,10 @@ func New() (e *Echo) {
224228 return
225229}
226230
231+ func (f MiddlewareFunc ) Process (h HandlerFunc ) HandlerFunc {
232+ return f (h )
233+ }
234+
227235// Router returns router.
228236func (e * Echo ) Router () * Router {
229237 return e .router
Original file line number Diff line number Diff line change @@ -61,15 +61,15 @@ func (s *Server) Start() {
6161 s .Handler = http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
6262 // Request
6363 req := s .pool .request .Get ().(* Request )
64- reqHdr := s .pool .request .Get ().(* Header )
65- reqURL := s .pool .request .Get ().(* URL )
64+ reqHdr := s .pool .header .Get ().(* Header )
65+ reqURL := s .pool .url .Get ().(* URL )
6666 reqHdr .reset (r .Header )
6767 reqURL .reset (r .URL )
6868 req .reset (r , reqHdr , reqURL )
6969
7070 // Response
71- res := s .pool .request .Get ().(* Response )
72- resHdr := s .pool .request .Get ().(* Header )
71+ res := s .pool .response .Get ().(* Response )
72+ resHdr := s .pool .header .Get ().(* Header )
7373 res .reset (w , reqHdr )
7474
7575 s .handler (req , res )
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ const (
1919//
2020// For valid credentials it calls the next handler.
2121// For invalid credentials, it sends "401 - Unauthorized" response.
22- func BasicAuth (fn BasicValidateFunc ) MiddlewareFunc {
22+ func BasicAuth (fn BasicValidateFunc ) echo. MiddlewareFunc {
2323 return func (h echo.HandlerFunc ) echo.HandlerFunc {
2424 return func (c echo.Context ) error {
2525 // Skip WebSocket
Original file line number Diff line number Diff line change @@ -48,7 +48,7 @@ var writerPool = sync.Pool{
4848
4949// Gzip returns a middleware which compresses HTTP response using gzip compression
5050// scheme.
51- func Gzip () MiddlewareFunc {
51+ func Gzip () echo. MiddlewareFunc {
5252 return func (h echo.HandlerFunc ) echo.HandlerFunc {
5353 scheme := "gzip"
5454
Original file line number Diff line number Diff line change 88 "github.com/labstack/gommon/color"
99)
1010
11- func Log () MiddlewareFunc {
11+ func Log () echo. MiddlewareFunc {
1212 return func (h echo.HandlerFunc ) echo.HandlerFunc {
1313 return func (c echo.Context ) error {
1414 req := c .Request ()
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ import (
1010
1111// Recover returns a middleware which recovers from panics anywhere in the chain
1212// and handles the control to the centralized HTTPErrorHandler.
13- func Recover () MiddlewareFunc {
13+ func Recover () echo. MiddlewareFunc {
1414 return func (h echo.HandlerFunc ) echo.HandlerFunc {
1515 // TODO: Provide better stack trace `https://github.com/go-errors/errors` `https://github.com/docker/libcontainer/tree/master/stacktrace`
1616 return func (c echo.Context ) error {
You can’t perform that action at this time.
0 commit comments