fix: Always add authorization if a token is provided
This commit is contained in:
parent
fbb80c622f
commit
aaab500049
@ -7,6 +7,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"code.gitea.io/sdk/gitea"
|
"code.gitea.io/sdk/gitea"
|
||||||
|
log "github.com/sirupsen/logrus"
|
||||||
|
|
||||||
"git.polynom.me/rio/internal/dns"
|
"git.polynom.me/rio/internal/dns"
|
||||||
)
|
)
|
||||||
@ -89,17 +90,19 @@ func NewGiteaClient(giteaUrl string, token string, giteaClient *gitea.Client) Gi
|
|||||||
path,
|
path,
|
||||||
branch,
|
branch,
|
||||||
)
|
)
|
||||||
|
log.Debugf("GetFile: Requesting '%s'", apiUrl)
|
||||||
client := &http.Client{}
|
client := &http.Client{}
|
||||||
req, err := http.NewRequest("GET", apiUrl, nil)
|
req, err := http.NewRequest("GET", apiUrl, nil)
|
||||||
if since != nil {
|
if since != nil {
|
||||||
sinceFormat := since.Format(time.RFC1123)
|
sinceFormat := since.Format(time.RFC1123)
|
||||||
req.Header.Add("If-Modified-Since", sinceFormat)
|
req.Header.Add("If-Modified-Since", sinceFormat)
|
||||||
|
}
|
||||||
|
|
||||||
// Add authentication, if we have a token
|
// Add authentication, if we have a token
|
||||||
if token != "" {
|
if token != "" {
|
||||||
req.Header.Add("Authorization", "token "+token)
|
req.Header.Add("Authorization", "token "+token)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
resp, err := client.Do(req)
|
resp, err := client.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return []byte{}, true, err
|
return []byte{}, true, err
|
||||||
|
Loading…
Reference in New Issue
Block a user