reverse_proxy_controller.go
973 字节
package mobile_client
import (
"fmt"
"github.com/beego/beego/v2/client/httplib"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/constant"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/port/beego/controllers"
)
//代理请求转发
type ReverseProxyController struct {
controllers.BaseController
}
func (controller *ReverseProxyController) SuplusSaleApp() {
//routePrefix := "/suplus-sale-app"
proxyHostUrl := constant.SUPLUS_SALE_APP + "/v1/platform/district"
req := httplib.Post(proxyHostUrl)
req.Header("Content-Type", "application/json")
req = req.Body(controller.Ctx.Input.RequestBody)
fmt.Println(string(controller.Ctx.Input.RequestBody))
// req.JSONBody() b.req.Header.Set(, "application/json")
respData, err := req.Bytes()
if err != nil {
controller.Response(nil, err)
return
}
controller.Ctx.Output.Header("Content-Type", "application/json; charset=utf-8")
controller.Ctx.Output.Body(respData)
}