@@ -64,6 +64,7 @@ import (
6464type (
6565 // Echo is the top-level framework instance.
6666 Echo struct {
67+ common
6768 StdLogger * stdLog.Logger
6869 colorer * color.Color
6970 premiddleware []MiddlewareFunc
@@ -125,10 +126,8 @@ type (
125126 // Map defines a generic map of type `map[string]interface{}`.
126127 Map map [string ]interface {}
127128
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 {}
132131)
133132
134133// HTTP methods
@@ -225,7 +224,7 @@ const (
225224
226225const (
227226 // Version of Echo
228- Version = "4.1.2 "
227+ Version = "4.1.3 "
229228 website = "https://echo.labstack.com"
230229 // http://patorjk.com/software/taag/#p=display&f=Small%20Slant&t=Echo
231230 banner = `
@@ -461,10 +460,10 @@ func (e *Echo) Static(prefix, root string) *Route {
461460 if root == "" {
462461 root = "." // For security we want to restrict to CWD.
463462 }
464- return static (e , prefix , root )
463+ return e . static (prefix , root , e . GET )
465464}
466465
467- func static ( i i , prefix , root string ) * Route {
466+ func ( _ common ) static ( prefix , root string , get func ( string , HandlerFunc , ... MiddlewareFunc ) * Route ) * Route {
468467 h := func (c Context ) error {
469468 p , err := url .PathUnescape (c .Param ("*" ))
470469 if err != nil {
@@ -473,21 +472,26 @@ func static(i i, prefix, root string) *Route {
473472 name := filepath .Join (root , path .Clean ("/" + p )) // "/"+ for security
474473 return c .File (name )
475474 }
476- i . GET (prefix , h )
475+ get (prefix , h )
477476 if prefix == "/" {
478- return i . GET (prefix + "*" , h )
477+ return get (prefix + "*" , h )
479478 }
480479
481- return i . GET (prefix + "/*" , h )
480+ return get (prefix + "/*" , h )
482481}
483482
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 {
487486 return c .File (file )
488487 }, m ... )
489488}
490489
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+
491495func (e * Echo ) add (host , method , path string , handler HandlerFunc , middleware ... MiddlewareFunc ) * Route {
492496 name := handlerName (handler )
493497 router := e .findRouter (host )
0 commit comments