File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -253,6 +253,12 @@ middleware. In addition to specified middleware group also inherits parent middl
253253To add middleware later in the group you can use ` Group.Use(m ...Middleware) ` .
254254Groups can also be nested.
255255
256+ ::: note
257+
258+ Group level middlewares are tied to the route and will work only if the group has at least one route.
259+
260+ :::
261+
256262### Basic Group Usage
257263
258264``` go
Original file line number Diff line number Diff line change @@ -16,6 +16,8 @@ e.Use(middleware.Static("/static"))
1616This serves static files from ` static ` directory. For example, a request to ` /js/main.js `
1717will fetch and serve ` static/js/main.js ` file.
1818
19+
20+
1921## Custom Configuration
2022
2123### Usage
@@ -38,8 +40,15 @@ Default behavior when using with non root URL paths is to append the URL path to
3840group := root.Group (" somepath" )
3941group.Use (middleware.Static (filepath.Join (" filesystempath" )))
4042// When an incoming request comes for `/somepath` the actual filesystem request goes to `filesystempath/somepath` instead of only `filesystempath`.
43+ group.GET (" /*" , func (c *echo.Context ) error { return echo.ErrNotFound })
4144```
4245
46+ ::: note
47+
48+ Group level middlewares are tied to the route and will work only if the group has at least one route.
49+
50+ :::
51+
4352::: tip
4453
4554To turn off this behavior set the ` IgnoreBase ` config param to ` true ` .
You can’t perform that action at this time.
0 commit comments