How can I rewrite the url before it is handled?



I want to rewrite the url before requests are handle. how can I achieve this?

my incoming request: => should become /bar.

Thanks in advance,


@rhvdwijngaard You can create a middleware and hook it up before the router is hit using API. Something like below:

package main

import (


func main() {
	e := echo.New()
	e.Pre(func(next echo.HandlerFunc) echo.HandlerFunc {
		return func(c echo.Context) error {
			if c.Request().URL.Path == "/service-name/bar" {
				c.Request().URL.Path = "/bar"
			return next(c)
	e.GET("/bar", func(c echo.Context) error {
		return c.String(http.StatusOK, "/bar")

PS: You can use some efficient code for matching the path.

Help with Reverse Proxying a subpage/bundle reload