move upstream into own package

This commit is contained in:
6543 2021-12-05 14:47:33 +01:00
parent f35c4d0f66
commit 38426c26db
No known key found for this signature in database
GPG key ID: C99B82E40B027BAE
7 changed files with 321 additions and 288 deletions

View file

@ -1,11 +1,14 @@
package server
import (
"github.com/OrlovEvgeny/go-mcache"
"github.com/valyala/fasthttp"
"net"
"strings"
"time"
"github.com/OrlovEvgeny/go-mcache"
"github.com/valyala/fasthttp"
"codeberg.org/codeberg/pages/server/upstream"
)
// DnsLookupCacheTimeout specifies the timeout for the DNS lookup cache.
@ -84,7 +87,7 @@ func checkCanonicalDomain(targetOwner, targetRepo, targetBranch, actualDomain, m
req.SetRequestURI(giteaRoot + "/api/v1/repos/" + targetOwner + "/" + targetRepo + "/raw/" + targetBranch + "/.domains" + "?access_token=" + giteaApiToken)
res := fasthttp.AcquireResponse()
err := upstreamClient.Do(req, res)
err := upstream.Client.Do(req, res)
if err == nil && res.StatusCode() == fasthttp.StatusOK {
for _, domain := range strings.Split(string(res.Body()), "\n") {
domain = strings.ToLower(domain)