mirror of
https://codeberg.org/video-prize-ranch/rimgo.git
synced 2026-01-28 01:21:16 +00:00
23 lines
476 B
Go
23 lines
476 B
Go
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
|
|
}
|