mirror of
https://codeberg.org/Codeberg/pages-server.git
synced 2025-04-24 13:56:57 +00:00
rm tmp
This commit is contained in:
parent
ec7fcca0f5
commit
6234889495
2 changed files with 4 additions and 22 deletions
|
@ -9,8 +9,6 @@ import (
|
|||
|
||||
"github.com/valyala/fasthttp"
|
||||
"github.com/valyala/fastjson"
|
||||
|
||||
"codeberg.org/codeberg/pages/server/shared"
|
||||
)
|
||||
|
||||
const giteaAPIRepos = "/api/v1/repos/"
|
||||
|
@ -46,7 +44,7 @@ func (client *Client) GiteaRawContent(targetOwner, targetRepo, ref, resource str
|
|||
req.Header.Set(fasthttp.HeaderAuthorization, client.giteaAPIToken)
|
||||
res := fasthttp.AcquireResponse()
|
||||
|
||||
if err := shared.GetFastHTTPClient(10*time.Second).Do(req, res); err != nil {
|
||||
if err := getFastHTTPClient(10*time.Second).Do(req, res); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if res.StatusCode() != fasthttp.StatusOK {
|
||||
|
@ -56,7 +54,7 @@ func (client *Client) GiteaRawContent(targetOwner, targetRepo, ref, resource str
|
|||
}
|
||||
|
||||
func (client *Client) ServeRawContent(uri string) (*fasthttp.Response, error) {
|
||||
fastClient := shared.GetFastHTTPClient(10 * time.Second)
|
||||
fastClient := getFastHTTPClient(10 * time.Second)
|
||||
|
||||
req := fasthttp.AcquireRequest()
|
||||
req.SetRequestURI(path.Join(client.giteaRoot, giteaAPIRepos, uri))
|
||||
|
@ -69,7 +67,7 @@ func (client *Client) ServeRawContent(uri string) (*fasthttp.Response, error) {
|
|||
}
|
||||
|
||||
func (client *Client) GiteaGetRepoBranchTimestamp(repoOwner, repoName, branchName string) (time.Time, error) {
|
||||
fastClient := shared.GetFastHTTPClient(5 * time.Second)
|
||||
fastClient := getFastHTTPClient(5 * time.Second)
|
||||
|
||||
req := fasthttp.AcquireRequest()
|
||||
req.SetRequestURI(path.Join(client.giteaRoot, giteaAPIRepos, repoOwner, repoName, "branches", branchName))
|
||||
|
@ -86,7 +84,7 @@ func (client *Client) GiteaGetRepoBranchTimestamp(repoOwner, repoName, branchNam
|
|||
}
|
||||
|
||||
func (client *Client) GiteaGetRepoDefaultBranch(repoOwner, repoName string) (string, error) {
|
||||
fastClient := shared.GetFastHTTPClient(5 * time.Second)
|
||||
fastClient := getFastHTTPClient(5 * time.Second)
|
||||
|
||||
req := fasthttp.AcquireRequest()
|
||||
req.SetRequestURI(path.Join(client.giteaRoot, giteaAPIRepos, repoOwner, repoName))
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
package shared
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/valyala/fasthttp"
|
||||
)
|
||||
|
||||
func GetFastHTTPClient(timeout time.Duration) *fasthttp.Client {
|
||||
return &fasthttp.Client{
|
||||
ReadTimeout: timeout,
|
||||
MaxConnDuration: 60 * time.Second,
|
||||
MaxConnWaitTimeout: 1000 * time.Millisecond,
|
||||
MaxConnsPerHost: 128 * 16, // TODO: adjust bottlenecks for best performance with Gitea!
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue