port most routes

This commit is contained in:
orangix
2026-01-19 18:57:06 +01:00
parent 04fbc7f5f4
commit cd4a36c9f7
17 changed files with 310 additions and 213 deletions

22
utils/accepts.go Normal file
View File

@@ -0,0 +1,22 @@
package utils
import (
"net/http"
"strings"
)
func Accepts(r *http.Request, format string) bool {
format = strings.ToLower(format)
group := strings.Split(format, "/")[0] + "/*"
header := r.Header.Get("Accept")
if header == "" {
return false
}
for _, mime := range strings.Split(header, ",") {
mime = strings.ToLower(strings.TrimSpace(strings.SplitN(mime, ";", 2)[0]))
if mime == "*/*" || mime == format || mime == group {
return true
}
}
return false
}