Skip to content

Commit

Permalink
fixed recipes for static middleware change
Browse files Browse the repository at this point in the history
Signed-off-by: Vishal Rana <[email protected]>
  • Loading branch information
vishr committed Oct 22, 2016
1 parent 166a24f commit 4760f4c
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 10 deletions.
6 changes: 5 additions & 1 deletion group.go
Original file line number Diff line number Diff line change
Expand Up @@ -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...)
}

Expand Down
5 changes: 2 additions & 3 deletions middleware/static.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion recipe/file-upload/multiple/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion recipe/file-upload/single/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion recipe/google-app-engine/app-standalone.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion recipe/jsonp/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion recipe/websocket/gorilla/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion recipe/websocket/net/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 4760f4c

Please sign in to comment.