Merge pull request #1334 from duyazhe/fix-baidu-bug
修复了百度请求时候需要传appid的bug
This commit is contained in:
@@ -42,7 +42,16 @@ func (a *Adaptor) GetRequestURL(info *relaycommon.RelayInfo) (string, error) {
|
|||||||
|
|
||||||
func (a *Adaptor) SetupRequestHeader(c *gin.Context, req *http.Header, info *relaycommon.RelayInfo) error {
|
func (a *Adaptor) SetupRequestHeader(c *gin.Context, req *http.Header, info *relaycommon.RelayInfo) error {
|
||||||
channel.SetupApiRequestHeader(info, c, req)
|
channel.SetupApiRequestHeader(info, c, req)
|
||||||
req.Set("Authorization", "Bearer "+info.ApiKey)
|
keyParts := strings.Split(info.ApiKey, "|")
|
||||||
|
if len(keyParts) == 0 || keyParts[0] == "" {
|
||||||
|
return errors.New("invalid API key: authorization token is required")
|
||||||
|
}
|
||||||
|
if len(keyParts) > 1 {
|
||||||
|
if keyParts[1] != "" {
|
||||||
|
req.Set("appid", keyParts[1])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
req.Set("Authorization", "Bearer "+keyParts[0])
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user