handle serve raw case

This commit is contained in:
6543 2022-09-18 21:56:56 +02:00
parent 8dac935cd8
commit 40478215d0
No known key found for this signature in database
GPG key ID: B8BE6D610E61C862
4 changed files with 56 additions and 43 deletions

View file

@ -1,10 +1,6 @@
package upstream
import (
"mime"
"path"
"strings"
"github.com/rs/zerolog/log"
"codeberg.org/codeberg/pages/server/gitea"
@ -34,23 +30,3 @@ func GetBranchTimestamp(giteaClient *gitea.Client, owner, repo, branch string) *
log.Debug().Msgf("Succesfully fetched latest commit's timestamp from branch: %#v", timestamp)
return timestamp
}
func (o *Options) getMimeTypeByExtension() string {
if o.ForbiddenMimeTypes == nil {
o.ForbiddenMimeTypes = make(map[string]bool)
}
mimeType := mime.TypeByExtension(path.Ext(o.TargetPath))
mimeTypeSplit := strings.SplitN(mimeType, ";", 2)
if o.ForbiddenMimeTypes[mimeTypeSplit[0]] || mimeType == "" {
if o.DefaultMimeType != "" {
mimeType = o.DefaultMimeType
} else {
mimeType = "application/octet-stream"
}
}
return mimeType
}
func (o *Options) generateUriClientArgs() (targetOwner, targetRepo, ref, resource string) {
return o.TargetOwner, o.TargetRepo, o.TargetBranch, o.TargetPath
}