From 7c8ed55e92ac3d268118f3b4840a8ee483cb01ec Mon Sep 17 00:00:00 2001 From: toim Date: Sun, 29 Mar 2026 22:27:58 +0300 Subject: [PATCH] Add not that group level middlewares need routes --- website/docs/guide/routing.md | 6 ++++++ website/docs/middleware/static.md | 9 +++++++++ 2 files changed, 15 insertions(+) diff --git a/website/docs/guide/routing.md b/website/docs/guide/routing.md index 876a2d0f..d4492d22 100644 --- a/website/docs/guide/routing.md +++ b/website/docs/guide/routing.md @@ -253,6 +253,12 @@ middleware. In addition to specified middleware group also inherits parent middl To add middleware later in the group you can use `Group.Use(m ...Middleware)`. Groups can also be nested. +:::note + +Group level middlewares are tied to the route and will work only if the group has at least one route. + +::: + ### Basic Group Usage ```go diff --git a/website/docs/middleware/static.md b/website/docs/middleware/static.md index bf26581f..401f8a32 100644 --- a/website/docs/middleware/static.md +++ b/website/docs/middleware/static.md @@ -16,6 +16,8 @@ e.Use(middleware.Static("/static")) This serves static files from `static` directory. For example, a request to `/js/main.js` will fetch and serve `static/js/main.js` file. + + ## Custom Configuration ### Usage @@ -38,8 +40,15 @@ Default behavior when using with non root URL paths is to append the URL path to group := root.Group("somepath") group.Use(middleware.Static(filepath.Join("filesystempath"))) // When an incoming request comes for `/somepath` the actual filesystem request goes to `filesystempath/somepath` instead of only `filesystempath`. +group.GET("/*", func(c *echo.Context) error { return echo.ErrNotFound }) ``` +:::note + +Group level middlewares are tied to the route and will work only if the group has at least one route. + +::: + :::tip To turn off this behavior set the `IgnoreBase` config param to `true`.