mirror of
https://codeberg.org/Codeberg/pages-server.git
synced 2025-04-25 14:26:58 +00:00
handle serve raw case
This commit is contained in:
parent
8dac935cd8
commit
40478215d0
4 changed files with 56 additions and 43 deletions
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue