split to move cache logic into it later

This commit is contained in:
6543 2022-07-21 21:41:56 +02:00
parent 00e8a41c89
commit 361639db68
No known key found for this signature in database
GPG key ID: C99B82E40B027BAE
2 changed files with 12 additions and 9 deletions

12
server/gitea/cache.go Normal file
View file

@ -0,0 +1,12 @@
package gitea
type FileResponse struct {
Exists bool
ETag []byte
MimeType string
Body []byte
}
func (f FileResponse) IsEmpty() bool {
return len(f.Body) != 0
}

View file

@ -23,13 +23,6 @@ type Client struct {
contentTimeout time.Duration
}
type FileResponse struct {
Exists bool
ETag []byte
MimeType string
Body []byte
}
// TODO: once golang v1.19 is min requirement, we can switch to 'JoinPath()' of 'net/url' package
func joinURL(baseURL string, paths ...string) string {
p := make([]string, 0, len(paths))
@ -44,8 +37,6 @@ func joinURL(baseURL string, paths ...string) string {
return baseURL + "/" + strings.Join(p, "/")
}
func (f FileResponse) IsEmpty() bool { return len(f.Body) != 0 }
func NewClient(giteaRoot, giteaAPIToken string) (*Client, error) {
rootURL, err := url.Parse(giteaRoot)
giteaRoot = strings.Trim(rootURL.String(), "/")