Skip to content

The proxy middleware is not forwarding requests #1808

@gustavosbarreto

Description

@gustavosbarreto

Issue Description

The proxy middleware is not forwarding requests

Expected behaviour

Middleware should be called to forward request to the another echo instance

> GET http://localhost:8081/resource/1 < HTTP 200 > PUT http://localhost:8081/resource/1 < HTTP 200 

Actual behaviour

Middleware is not called and I'm getting back a 405 status code (method not allowed)

> GET http://localhost:8081/resource/1 < HTTP 405 > PUT http://localhost:8081/resource/1 < HTTP 200 

Steps to reproduce

GET http://localhost:8081/resource/1 

Working code to debug

package main import ( "net/http" "net/url" "github.com/labstack/echo" "github.com/labstack/echo/middleware" ) func main() { // echo instance 1 e1 := echo.New() g1 := e1.Group("/api") g1.GET("/resource/:id", func(c echo.Context) error { return c.NoContent(http.StatusOK)	}) e1url, _ := url.Parse("http://localhost:8080") // echo instance 2 e2 := echo.New() g2 := e2.Group("/api") g2.PUT("/resource/:id", func(c echo.Context) error { return c.NoContent(http.StatusOK)	}) g2.Use(middleware.Proxy(middleware.NewRoundRobinBalancer([]*middleware.ProxyTarget{	{ URL: e1url, // forward all requests with /api prefix to server running on port 8080 (except PUT /resource/:id)	},	}))) go e1.Start(":8080") e2.Start(":8081") }

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions