pages-server/server/gitea/client.go

36 lines
680 B
Go
Raw Normal View History

package gitea
import (
"errors"
"strings"
)
const giteaAPIRepos = "/api/v1/repos/"
var ErrorNotFound = errors.New("not found")
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))
for i := range paths {
path := strings.TrimSpace(paths[i])
path = strings.Trim(path, "/")
if len(path) != 0 {
p = append(p, path)
}
}
return baseURL + "/" + strings.Join(p, "/")
}
2022-07-15 16:53:04 +00:00
func (f FileResponse) IsEmpty() bool {
return len(f.Body) != 0
}