mirror of
https://codeberg.org/Codeberg/pages-server.git
synced 2025-05-03 01:17:50 +00:00
gitea auth only in header & gitea calls in own func
This commit is contained in:
parent
4794318791
commit
06b6875f95
4 changed files with 62 additions and 26 deletions
server/upstream
|
@ -5,6 +5,7 @@ import (
|
|||
"net/url"
|
||||
"path"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/valyala/fasthttp"
|
||||
|
||||
|
@ -19,11 +20,11 @@ func CheckCanonicalDomain(targetOwner, targetRepo, targetBranch, actualDomain, m
|
|||
func giteaRawContent(targetOwner, targetRepo, ref, giteaRoot, giteaAPIToken, resource string) ([]byte, error) {
|
||||
req := fasthttp.AcquireRequest()
|
||||
|
||||
req.SetRequestURI(path.Join(giteaRoot, giteaApiRepos, targetOwner, "/", targetRepo, "/raw/", resource, "?ref="+url.QueryEscape(ref)))
|
||||
req.SetRequestURI(path.Join(giteaRoot, giteaApiRepos, targetOwner, targetRepo, "raw", resource+"?ref="+url.QueryEscape(ref)))
|
||||
req.Header.Set(fasthttp.HeaderAuthorization, giteaAPIToken)
|
||||
res := fasthttp.AcquireResponse()
|
||||
|
||||
if err := client.Do(req, res); err != nil {
|
||||
if err := getFastHTTPClient(10*time.Second).Do(req, res); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if res.StatusCode() != fasthttp.StatusOK {
|
||||
|
@ -46,7 +47,6 @@ func checkCanonicalDomain(targetOwner, targetRepo, targetBranch, actualDomain, m
|
|||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
body, err := giteaRawContent(giteaRoot, targetRepo, targetBranch, giteaRoot, giteaAPIToken, canonicalDomainConfig)
|
||||
if err == nil {
|
||||
for _, domain := range strings.Split(string(body), "\n") {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue