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 (
55
55
message string
56
56
}
57
57
58
- // Middleware interface{}
58
+ Middleware interface {
59
+ Process (HandlerFunc ) HandlerFunc
60
+ }
61
+
59
62
MiddlewareFunc func (HandlerFunc ) HandlerFunc
63
+
60
64
// Handler interface{}
61
65
HandlerFunc func (Context ) error
62
66
@@ -224,6 +228,10 @@ func New() (e *Echo) {
224
228
return
225
229
}
226
230
231
+ func (f MiddlewareFunc ) Process (h HandlerFunc ) HandlerFunc {
232
+ return f (h )
233
+ }
234
+
227
235
// Router returns router.
228
236
func (e * Echo ) Router () * Router {
229
237
return e .router
Original file line number Diff line number Diff line change @@ -61,15 +61,15 @@ func (s *Server) Start() {
61
61
s .Handler = http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
62
62
// Request
63
63
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 )
66
66
reqHdr .reset (r .Header )
67
67
reqURL .reset (r .URL )
68
68
req .reset (r , reqHdr , reqURL )
69
69
70
70
// 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 )
73
73
res .reset (w , reqHdr )
74
74
75
75
s .handler (req , res )
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ const (
19
19
//
20
20
// For valid credentials it calls the next handler.
21
21
// For invalid credentials, it sends "401 - Unauthorized" response.
22
- func BasicAuth (fn BasicValidateFunc ) MiddlewareFunc {
22
+ func BasicAuth (fn BasicValidateFunc ) echo. MiddlewareFunc {
23
23
return func (h echo.HandlerFunc ) echo.HandlerFunc {
24
24
return func (c echo.Context ) error {
25
25
// Skip WebSocket
Original file line number Diff line number Diff line change @@ -48,7 +48,7 @@ var writerPool = sync.Pool{
48
48
49
49
// Gzip returns a middleware which compresses HTTP response using gzip compression
50
50
// scheme.
51
- func Gzip () MiddlewareFunc {
51
+ func Gzip () echo. MiddlewareFunc {
52
52
return func (h echo.HandlerFunc ) echo.HandlerFunc {
53
53
scheme := "gzip"
54
54
Original file line number Diff line number Diff line change 8
8
"github.com/labstack/gommon/color"
9
9
)
10
10
11
- func Log () MiddlewareFunc {
11
+ func Log () echo. MiddlewareFunc {
12
12
return func (h echo.HandlerFunc ) echo.HandlerFunc {
13
13
return func (c echo.Context ) error {
14
14
req := c .Request ()
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ import (
10
10
11
11
// Recover returns a middleware which recovers from panics anywhere in the chain
12
12
// and handles the control to the centralized HTTPErrorHandler.
13
- func Recover () MiddlewareFunc {
13
+ func Recover () echo. MiddlewareFunc {
14
14
return func (h echo.HandlerFunc ) echo.HandlerFunc {
15
15
// TODO: Provide better stack trace `https://github.com/go-errors/errors` `https://github.com/docker/libcontainer/tree/master/stacktrace`
16
16
return func (c echo.Context ) error {
You can’t perform that action at this time.
0 commit comments