mirror of
https://github.com/thomiceli/opengist.git
synced 2025-07-09 01:18:04 +02:00
feat: add MIME type support for raw file serving (#417)
This commit is contained in:
@ -2,10 +2,12 @@ package handlers
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"github.com/thomiceli/opengist/internal/web/context"
|
||||
"html/template"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/thomiceli/opengist/internal/web/context"
|
||||
)
|
||||
|
||||
func GetPage(ctx *context.Context) int {
|
||||
@ -77,3 +79,13 @@ func ParseSearchQueryStr(query string) (string, map[string]string) {
|
||||
content := strings.TrimSpace(contentBuilder.String())
|
||||
return content, metadata
|
||||
}
|
||||
|
||||
func GetContentTypeFromFilename(filename string) string {
|
||||
ext := strings.ToLower(filepath.Ext(filename))
|
||||
switch ext {
|
||||
case ".css":
|
||||
return "text/css"
|
||||
default:
|
||||
return "text/plain"
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user