Skip to content

rewrite middleware does not call next() #1054

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
rvdwijngaard opened this issue Jan 30, 2018 · 1 comment
Closed

rewrite middleware does not call next() #1054

rvdwijngaard opened this issue Jan 30, 2018 · 1 comment
Assignees
Labels

Comments

@rvdwijngaard
Copy link

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

@vishr vishr closed this as completed in ea36812 Jan 30, 2018
@vishr vishr self-assigned this Jan 30, 2018
@vishr vishr added the bug label Jan 30, 2018
@vishr
Copy link
Member

vishr commented Jan 30, 2018

Please use it as e.Pre() as it should trigger before router.

vishr pushed a commit that referenced this issue Jan 30, 2018
Signed-off-by: Vishal Rana <[email protected]>
vishr added a commit that referenced this issue Jan 30, 2018
Signed-off-by: Vishal Rana <[email protected]>
vishr pushed a commit that referenced this issue Mar 12, 2018
Enhancements:
    Implemented Response#After()
    Dynamically add/remove proxy targets
    Rewrite rules for proxy middleware
    Add ability to extract key from a form field
    Implemented rewrite middleware
    Adds a separate flag for the 'http/https server started on' message (#1043)
    Applied a little DRY to the redirect middleware (#1053) and tests (#1055)
    Simplify dep fetching (#1062)
    Add custom time stamp format #1046 (#1066)
    Update property name & default value & comment about custom logger
    Add X-Requested-With header constant
    Return error of context.File in c.contentDisposition
    Updated deps
    Updated README.md

Fixes:

    Fixed Response#Before()
    Fixed #990
    Fix href url from armor to echo (#1051)
    Fixed #1054
    Fixed #1052, dropped param alias feature
    Avoid redirect loop in HTTPSRedirect middleware (#1058)
    Fix deferring body close in middleware/compress test (#1063)
    Cleanup code (#1061)
    FIX - We must close gzip.Reader, only if no error (#1069)
    Fix formatting (#1071)
    Can be a fix for auto TLS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants