mirror of
https://codeberg.org/Codeberg/pages-server.git
synced 2025-04-29 09:33:36 +02:00
35 lines
680 B
Go
35 lines
680 B
Go
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, "/")
|
|
}
|
|
|
|
func (f FileResponse) IsEmpty() bool {
|
|
return len(f.Body) != 0
|
|
}
|