Skip to content

Rewrite middleware does not work on latest commit #1086

Closed
@rvdwijngaard

Description

@rvdwijngaard

/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
/ / / / / / / / / / / / / / / / / /

Please use forum https://forum.labstack.com to ask questions!

/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
/ / / / / / / / / / / / / / / / / /

Issue Description

Checklist

  • Dependencies installed
  • No typos
  • Searched existing issues and docs

Expected behaviour

rewrite middleware should rewrite the url as configured

Actual behaviour

it returns a 404

Steps to reproduce

  • get the latest version of echo (at least commit 7f44549)

Working code to debug

package main

import (
	"github.com/labstack/echo"
	"github.com/labstack/echo/middleware"
)

func main() {
	e := echo.New()
	e.Pre(middleware.RewriteWithConfig(middleware.RewriteConfig{
		Rules: map[string]string{
			"/old":              "/new",
			"/api/*":            "/$1",
			"/js/*":             "/public/javascripts/$1",
			"/users/*/orders/*": "/user/$1/order/$2",
		},
	}))
	e.GET("/users", func(c echo.Context) error {
		return c.String(200, "Yeah")
	})
	e.Logger.Fatal(e.Start(":8080"))
}

and than a curl :

curl localhost:8080/api/users

this returns a 404

When running this program with commit f4dde46 it works as expected.

Version/commit

7f44549

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions