Skip to content

Commit a033b2c

Browse files
committed
Add not that group level middlewares need routes
1 parent dbd619b commit a033b2c

2 files changed

Lines changed: 15 additions & 0 deletions

File tree

website/docs/guide/routing.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,12 @@ middleware. In addition to specified middleware group also inherits parent middl
253253
To add middleware later in the group you can use `Group.Use(m ...Middleware)`.
254254
Groups 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

website/docs/middleware/static.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ e.Use(middleware.Static("/static"))
1616
This serves static files from `static` directory. For example, a request to `/js/main.js`
1717
will 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
3840
group := root.Group("somepath")
3941
group.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

4554
To turn off this behavior set the `IgnoreBase` config param to `true`.

0 commit comments

Comments
 (0)