Skip to content

rewrite middleware does not call next()  #1054

Closed
@rvdwijngaard

Description

@rvdwijngaard

Issue Description

I want to use the rewrite middleware because my url schema has changed. Using this middleware will not forward requests to the handler functions.

Checklist

  • [x ] Dependencies installed
  • [ x] No typos
  • [ x] Searched existing issues and docs

Expected behaviour

I expect this middleware to rewrite the url and forward the request to the appropriate handler.

Actual behaviour

Middleware does not call next(c) and thus it stops the chain.

Steps to reproduce

  1. start an echo server with rewrite middleware
  2. do a request
  3. service returns a 200 - OK regardless the request url

Working code to debug

func main() {
        e := echo.New()
	e.Use(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 now a curl :

 curl http://localhost:8080/api/users -i           

Version/commit

f710bf6

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions