Golang杜松子酒gonic web框架代理路由到另一个后端 [英] Golang gin gonic web framework proxy route to another backend
问题描述
如何在杜松子酒网站上将代理网络请求的几条路线反向转发到另一个后端golang框架
有没有一种方法可以直接在Handle函数中转发,如下所示?
router:= gin.New()
router.Handle(POST,/ api / v1 / endpoint1,ForwardToAnotherBackend)
您可以使用标准库 httputil.ReverseProxy 。
我还没找到使用杜松子酒的理由,尽可能坚持stdlib的粉丝。
但是我相信你可以在 gin.WrapH()
中包装这个ReverseProxy处理程序,以便能够在你的杜松子酒路由器中使用它。
How to reverse proxy web requests for a few routes to another backend in Gin Gonic web golang framework
Is there a way to directly forward in the Handle function as shown below?
router := gin.New()
router.Handle("POST", "/api/v1/endpoint1", ForwardToAnotherBackend)
You can do this with the standard library httputil.ReverseProxy.
I haven't found a reason to use gin myself yet, I'm a fan of sticking to stdlib whenever possible.
However I believe you can wrap this ReverseProxy handler in gin.WrapH()
to be able to use it with your gin router.
这篇关于Golang杜松子酒gonic web框架代理路由到另一个后端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!