This commit is contained in:
WJQSERVER 2024-12-31 19:41:00 +08:00
parent be6314bd53
commit 546a8ca981
10 changed files with 37 additions and 19 deletions

View file

@ -197,6 +197,7 @@ func ProxyRequest(c *gin.Context, u string, cfg *config.Config, mode string) {
req := client.R().SetBody(body)
setRequestHeaders(c, req)
authPassThrough(c, cfg)
resp, err := SendRequest(c, req, method, u)
if err != nil {
@ -250,6 +251,16 @@ func setRequestHeaders(c *gin.Context, req *req.Request) {
}
}
func authPassThrough(c *gin.Context, cfg *config.Config) {
// 判断
if cfg.Auth.AuthMethod == "parameters" && !cfg.Auth.Enabled {
// 获取参数(token)
token := c.Query("token")
// 写入Header
c.Header("Authorization", "token "+token)
}
}
// 复制响应体
func copyResponseBody(c *gin.Context, respBody io.Reader) error {
_, err := io.Copy(c.Writer, respBody)