@@ -64,6 +64,7 @@ import (
64
64
type (
65
65
// Echo is the top-level framework instance.
66
66
Echo struct {
67
+ common
67
68
StdLogger * stdLog.Logger
68
69
colorer * color.Color
69
70
premiddleware []MiddlewareFunc
@@ -125,10 +126,8 @@ type (
125
126
// Map defines a generic map of type `map[string]interface{}`.
126
127
Map map [string ]interface {}
127
128
128
- // i is the interface for Echo and Group.
129
- i interface {
130
- GET (string , HandlerFunc , ... MiddlewareFunc ) * Route
131
- }
129
+ // Common struct for Echo & Group.
130
+ common struct {}
132
131
)
133
132
134
133
// HTTP methods
@@ -225,7 +224,7 @@ const (
225
224
226
225
const (
227
226
// Version of Echo
228
- Version = "4.1.2 "
227
+ Version = "4.1.3 "
229
228
website = "https://echo.labstack.com"
230
229
// http://patorjk.com/software/taag/#p=display&f=Small%20Slant&t=Echo
231
230
banner = `
@@ -461,10 +460,10 @@ func (e *Echo) Static(prefix, root string) *Route {
461
460
if root == "" {
462
461
root = "." // For security we want to restrict to CWD.
463
462
}
464
- return static (e , prefix , root )
463
+ return e . static (prefix , root , e . GET )
465
464
}
466
465
467
- func static ( i i , prefix , root string ) * Route {
466
+ func ( _ common ) static ( prefix , root string , get func ( string , HandlerFunc , ... MiddlewareFunc ) * Route ) * Route {
468
467
h := func (c Context ) error {
469
468
p , err := url .PathUnescape (c .Param ("*" ))
470
469
if err != nil {
@@ -473,21 +472,26 @@ func static(i i, prefix, root string) *Route {
473
472
name := filepath .Join (root , path .Clean ("/" + p )) // "/"+ for security
474
473
return c .File (name )
475
474
}
476
- i . GET (prefix , h )
475
+ get (prefix , h )
477
476
if prefix == "/" {
478
- return i . GET (prefix + "*" , h )
477
+ return get (prefix + "*" , h )
479
478
}
480
479
481
- return i . GET (prefix + "/*" , h )
480
+ return get (prefix + "/*" , h )
482
481
}
483
482
484
- // File registers a new route with path to serve a static file with optional route-level middleware.
485
- func ( e * Echo ) File ( path , file string , m ... MiddlewareFunc ) * Route {
486
- return e . GET (path , func (c Context ) error {
483
+ func ( _ common ) file ( path , file string , get func ( string , HandlerFunc , ... MiddlewareFunc ) * Route ,
484
+ m ... MiddlewareFunc ) * Route {
485
+ return get (path , func (c Context ) error {
487
486
return c .File (file )
488
487
}, m ... )
489
488
}
490
489
490
+ // File registers a new route with path to serve a static file with optional route-level middleware.
491
+ func (e * Echo ) File (path , file string , m ... MiddlewareFunc ) * Route {
492
+ return e .file (path , file , e .GET , m ... )
493
+ }
494
+
491
495
func (e * Echo ) add (host , method , path string , handler HandlerFunc , middleware ... MiddlewareFunc ) * Route {
492
496
name := handlerName (handler )
493
497
router := e .findRouter (host )
0 commit comments