mirror of
https://codeberg.org/Codeberg/pages-server.git
synced 2025-01-19 08:57:55 +00:00
split to move cache logic into it later
This commit is contained in:
parent
00e8a41c89
commit
361639db68
2 changed files with 12 additions and 9 deletions
12
server/gitea/cache.go
Normal file
12
server/gitea/cache.go
Normal 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
|
||||||
|
}
|
|
@ -23,13 +23,6 @@ type Client struct {
|
||||||
contentTimeout time.Duration
|
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
|
// TODO: once golang v1.19 is min requirement, we can switch to 'JoinPath()' of 'net/url' package
|
||||||
func joinURL(baseURL string, paths ...string) string {
|
func joinURL(baseURL string, paths ...string) string {
|
||||||
p := make([]string, 0, len(paths))
|
p := make([]string, 0, len(paths))
|
||||||
|
@ -44,8 +37,6 @@ func joinURL(baseURL string, paths ...string) string {
|
||||||
return baseURL + "/" + strings.Join(p, "/")
|
return baseURL + "/" + strings.Join(p, "/")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f FileResponse) IsEmpty() bool { return len(f.Body) != 0 }
|
|
||||||
|
|
||||||
func NewClient(giteaRoot, giteaAPIToken string) (*Client, error) {
|
func NewClient(giteaRoot, giteaAPIToken string) (*Client, error) {
|
||||||
rootURL, err := url.Parse(giteaRoot)
|
rootURL, err := url.Parse(giteaRoot)
|
||||||
giteaRoot = strings.Trim(rootURL.String(), "/")
|
giteaRoot = strings.Trim(rootURL.String(), "/")
|
||||||
|
|
Loading…
Reference in a new issue