rootPathMiddleware sets the root path in the [echo.Context] under "rootPath". Its value may be used to skip a middleware execution based on a request URI. rootPath := c.Get("rootPath").(string) healthURI := fmt.Sprintf("%s/health", rootPath) // Skip the middleware if it's the health check URI.
(rootPath string)
| 133 | // return next(c) |
| 134 | // } |
| 135 | func rootPathMiddleware(rootPath string) echo.MiddlewareFunc { |
| 136 | return func(next echo.HandlerFunc) echo.HandlerFunc { |
| 137 | return func(c echo.Context) error { |
| 138 | c.Set("rootPath", rootPath) |
| 139 | // Call the next middleware in the chain. |
| 140 | return next(c) |
| 141 | } |
| 142 | } |
| 143 | } |
| 144 | |
| 145 | // outputFilenameMiddleware sets the output filename in the [echo.Context] |
| 146 | // under "outputFilename". |