mirror of
https://codeberg.org/Codeberg/pages-server.git
synced 2025-04-24 13:56:57 +00:00
fix gitea client
path.Join() mangles giteaRoot by changing https://codeberg.org to https:/codeberg.org This causes the upstream requests to fail every time, always resulting in 424 Failed Dependency
This commit is contained in:
parent
cde2137df0
commit
7be32d4de2
1 changed files with 6 additions and 4 deletions
|
@ -27,6 +27,8 @@ type FileResponse struct {
|
|||
Body []byte
|
||||
}
|
||||
|
||||
func joinURL(giteaRoot string, paths ...string) string { return giteaRoot + path.Join(paths...) }
|
||||
|
||||
func (f FileResponse) IsEmpty() bool { return len(f.Body) != 0 }
|
||||
|
||||
func NewClient(giteaRoot, giteaAPIToken string) *Client {
|
||||
|
@ -42,7 +44,7 @@ func NewClient(giteaRoot, giteaAPIToken string) *Client {
|
|||
func (client *Client) GiteaRawContent(targetOwner, targetRepo, ref, resource string) ([]byte, error) {
|
||||
req := fasthttp.AcquireRequest()
|
||||
|
||||
req.SetRequestURI(path.Join(client.giteaRoot, giteaAPIRepos, targetOwner, targetRepo, "raw", resource+"?ref="+url.QueryEscape(ref)))
|
||||
req.SetRequestURI(joinURL(client.giteaRoot, giteaAPIRepos, targetOwner, targetRepo, "raw", resource+"?ref="+url.QueryEscape(ref)))
|
||||
req.Header.Set(fasthttp.HeaderAuthorization, client.giteaAPIToken)
|
||||
res := fasthttp.AcquireResponse()
|
||||
|
||||
|
@ -63,7 +65,7 @@ func (client *Client) ServeRawContent(uri string) (*fasthttp.Response, error) {
|
|||
fastClient := getFastHTTPClient(10 * time.Second)
|
||||
|
||||
req := fasthttp.AcquireRequest()
|
||||
req.SetRequestURI(path.Join(client.giteaRoot, giteaAPIRepos, uri))
|
||||
req.SetRequestURI(joinURL(client.giteaRoot, giteaAPIRepos, uri))
|
||||
req.Header.Set(fasthttp.HeaderAuthorization, client.giteaAPIToken)
|
||||
|
||||
resp := fasthttp.AcquireResponse()
|
||||
|
@ -87,7 +89,7 @@ func (client *Client) GiteaGetRepoBranchTimestamp(repoOwner, repoName, branchNam
|
|||
fastClient := getFastHTTPClient(5 * time.Second)
|
||||
|
||||
req := fasthttp.AcquireRequest()
|
||||
req.SetRequestURI(path.Join(client.giteaRoot, giteaAPIRepos, repoOwner, repoName, "branches", branchName))
|
||||
req.SetRequestURI(joinURL(client.giteaRoot, giteaAPIRepos, repoOwner, repoName, "branches", branchName))
|
||||
req.Header.Set(fasthttp.HeaderAuthorization, client.giteaAPIToken)
|
||||
res := fasthttp.AcquireResponse()
|
||||
|
||||
|
@ -104,7 +106,7 @@ func (client *Client) GiteaGetRepoDefaultBranch(repoOwner, repoName string) (str
|
|||
fastClient := getFastHTTPClient(5 * time.Second)
|
||||
|
||||
req := fasthttp.AcquireRequest()
|
||||
req.SetRequestURI(path.Join(client.giteaRoot, giteaAPIRepos, repoOwner, repoName))
|
||||
req.SetRequestURI(joinURL(client.giteaRoot, giteaAPIRepos, repoOwner, repoName))
|
||||
req.Header.Set(fasthttp.HeaderAuthorization, client.giteaAPIToken)
|
||||
res := fasthttp.AcquireResponse()
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue