echo icon indicating copy to clipboard operation
echo copied to clipboard

Proxy middleware: add ModifyRequest function to modify http.Request before proxy

Open binhnguyenduc opened this issue 3 years ago • 3 comments

The proxy middleware currently does not allow any modification to the request, only ModifyResponse. This PR adds that option so caller can pass a custom function to be applied to requests before it hits reverse proxy.

I have also added passing test.

Please consider merging this as it would allow for more flexibility when proxy with Echo.

Thanks!

binhnguyenduc avatar Dec 14 '21 03:12 binhnguyenduc

@aldas is it possible to modify the proxy target urls at runtime?

asad-awadia avatar Feb 14 '22 14:02 asad-awadia

I think you are looking for: https://github.com/labstack/echo/blob/4a1ccdfdc520eb90573a97a7d04fd9fc300c1629/middleware/proxy.go#L69 and look how commonBalancer works

aldas avatar Feb 14 '22 14:02 aldas

@aldas oh so I can use the returned object from NewRoundRobinBalancer to change the proxy targets by calling the appropriate methods?

The interface is already implemented internally? I just have to call addTarget with the right parameter ?

asad-awadia avatar Feb 14 '22 15:02 asad-awadia