diff --git a/group.go b/group.go index 2b6898b2..cd77abf8 100644 --- a/group.go +++ b/group.go @@ -19,7 +19,11 @@ func (g *Group) Use(middleware ...MiddlewareFunc) { // Allow requests `/prefix & /prefix/*` to reach the group as they might get // dropped if router doesn't find a match, making none of the group middleware // execute. - g.Any("", NotFoundHandler, g.middleware...) + p := "" + if g.prefix == "" { + p = "/" + } + g.Any(p, NotFoundHandler, g.middleware...) g.Any("/*", NotFoundHandler, g.middleware...) } diff --git a/middleware/static.go b/middleware/static.go index ad9a8e06..7d3aadf7 100644 --- a/middleware/static.go +++ b/middleware/static.go @@ -16,7 +16,7 @@ type ( Skipper Skipper // Prefix to strip from the request URL path. - // Required. + // Optional. Default value "". Prefix string `json:"root"` // Root directory from where the static content is served. @@ -48,9 +48,8 @@ var ( // Static returns a Static middleware to serves static content from the provided // root directory. -func Static(prefix, root string) echo.MiddlewareFunc { +func Static(root string) echo.MiddlewareFunc { c := DefaultStaticConfig - c.Prefix = prefix c.Root = root return StaticWithConfig(c) } diff --git a/recipe/file-upload/multiple/server.go b/recipe/file-upload/multiple/server.go index 5a70ec0c..292d64f9 100644 --- a/recipe/file-upload/multiple/server.go +++ b/recipe/file-upload/multiple/server.go @@ -57,7 +57,7 @@ func main() { e.Use(middleware.Logger()) e.Use(middleware.Recover()) - e.Use(middleware.Static("public")) + e.Use(middleware.Static( "public")) e.POST("/upload", upload) diff --git a/recipe/file-upload/single/server.go b/recipe/file-upload/single/server.go index d7ea8f34..4048aa58 100644 --- a/recipe/file-upload/single/server.go +++ b/recipe/file-upload/single/server.go @@ -51,7 +51,7 @@ func main() { e.Use(middleware.Logger()) e.Use(middleware.Recover()) - e.Use(middleware.Static("public")) + e.Use(middleware.Static( "public")) e.POST("/upload", upload) diff --git a/recipe/google-app-engine/app-standalone.go b/recipe/google-app-engine/app-standalone.go index c142a314..f6dd1252 100644 --- a/recipe/google-app-engine/app-standalone.go +++ b/recipe/google-app-engine/app-standalone.go @@ -14,7 +14,7 @@ func createMux() *echo.Echo { e.Use(middleware.Logger()) e.Use(middleware.Gzip()) - e.Use(middleware.Static("public")) + e.Use(middleware.Static( "public")) return e } diff --git a/recipe/jsonp/server.go b/recipe/jsonp/server.go index 213bf34d..6156b61c 100644 --- a/recipe/jsonp/server.go +++ b/recipe/jsonp/server.go @@ -13,7 +13,7 @@ func main() { e := echo.New() e.Use(middleware.Logger()) e.Use(middleware.Recover()) - e.Use(middleware.Static("public")) + e.Use(middleware.Static( "public")) // JSONP e.GET("/jsonp", func(c echo.Context) error { diff --git a/recipe/websocket/gorilla/server.go b/recipe/websocket/gorilla/server.go index b20ca781..9711b43a 100644 --- a/recipe/websocket/gorilla/server.go +++ b/recipe/websocket/gorilla/server.go @@ -41,7 +41,7 @@ func main() { e := echo.New() e.Use(middleware.Logger()) e.Use(middleware.Recover()) - e.Use(middleware.Static("../public")) + e.Use(middleware.Static( "../public")) e.GET("/ws", hello) if err := e.Start(":1323"); err != nil { panic(err) diff --git a/recipe/websocket/net/server.go b/recipe/websocket/net/server.go index 078392fc..a5195a98 100644 --- a/recipe/websocket/net/server.go +++ b/recipe/websocket/net/server.go @@ -35,7 +35,7 @@ func main() { e := echo.New() e.Use(middleware.Logger()) e.Use(middleware.Recover()) - e.Use(middleware.Static("../public")) + e.Use(middleware.Static( "../public")) e.GET("/ws", hello) if err := e.Start(":1323"); err != nil { panic(err)