mirror of
https://github.com/mainnika/nikita-tokarch-uk.git
synced 2026-05-25 01:03:35 +00:00
Support additional headers for the ghost http client
This commit is contained in:
@@ -25,6 +25,7 @@ type HTTPClient struct {
|
||||
ContentKey string
|
||||
Addr string
|
||||
Secured bool
|
||||
Headers map[string]string
|
||||
|
||||
client *fasthttp.HostClient
|
||||
|
||||
@@ -63,6 +64,9 @@ func (g *HTTPClient) doQuery(method string, v easyjson.Unmarshaler, params ...Qu
|
||||
uri.SetScheme("https")
|
||||
}
|
||||
|
||||
for hKey, hValue := range g.Headers {
|
||||
req.Header.Add(hKey, hValue)
|
||||
}
|
||||
for _, param := range params {
|
||||
param.Apply(&req.Header, uri.QueryArgs())
|
||||
}
|
||||
@@ -78,7 +82,6 @@ func (g *HTTPClient) doQuery(method string, v easyjson.Unmarshaler, params ...Qu
|
||||
resBytes := res.Body()
|
||||
if resBytes == nil && v == nil {
|
||||
return fmt.Errorf("nothing to unmarshal")
|
||||
|
||||
}
|
||||
if resBytes == nil {
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user