Skip to content

Commit 891d851

Browse files
committed
fixed #701
Signed-off-by: Vishal Rana <[email protected]>
1 parent 796df51 commit 891d851

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

echo.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,11 @@ type (
121121

122122
// Map defines a generic map of type `map[string]interface{}`.
123123
Map map[string]interface{}
124+
125+
// i is the interface for Echo and Group.
126+
i interface {
127+
GET(string, HandlerFunc, ...MiddlewareFunc)
128+
}
124129
)
125130

126131
// HTTP methods
@@ -384,14 +389,18 @@ func (e *Echo) Match(methods []string, path string, handler HandlerFunc, middlew
384389
// Static registers a new route with path prefix to serve static files from the
385390
// provided root directory.
386391
func (e *Echo) Static(prefix, root string) {
392+
static(e, prefix, root)
393+
}
394+
395+
func static(i i, prefix, root string) {
387396
h := func(c Context) error {
388397
return c.File(path.Join(root, c.Param("*")))
389398
}
390-
e.GET(prefix, h)
399+
i.GET(prefix, h)
391400
if prefix == "/" {
392-
e.GET(prefix+"*", h)
401+
i.GET(prefix+"*", h)
393402
} else {
394-
e.GET(prefix+"/*", h)
403+
i.GET(prefix+"/*", h)
395404
}
396405
}
397406

group.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ func (g *Group) Group(prefix string, middleware ...MiddlewareFunc) *Group {
8585

8686
// Static implements `Echo#Static()` for sub-routes within the Group.
8787
func (g *Group) Static(prefix, root string) {
88-
g.echo.Static(g.prefix+prefix, root)
88+
static(g, prefix, root)
8989
}
9090

9191
// File implements `Echo#File()` for sub-routes within the Group.

0 commit comments

Comments
 (0)