mirror of
https://github.com/WJQSERVER-STUDIO/ghproxy.git
synced 2026-02-03 00:01:10 +08:00
24w29a
This commit is contained in:
parent
be6314bd53
commit
546a8ca981
10 changed files with 37 additions and 19 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue