mirror of
https://github.com/rancher/steve.git
synced 2025-09-06 18:01:04 +00:00
Refactor
This commit is contained in:
18
pkg/schemaserver/parse/browser.go
Normal file
18
pkg/schemaserver/parse/browser.go
Normal file
@@ -0,0 +1,18 @@
|
||||
package parse
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func IsBrowser(req *http.Request, checkAccepts bool) bool {
|
||||
accepts := strings.ToLower(req.Header.Get("Accept"))
|
||||
userAgent := strings.ToLower(req.Header.Get("User-Agent"))
|
||||
|
||||
if accepts == "" || !checkAccepts {
|
||||
accepts = "*/*"
|
||||
}
|
||||
|
||||
// User agent has Mozilla and browser accepts */*
|
||||
return strings.Contains(userAgent, "mozilla") && strings.Contains(accepts, "*/*")
|
||||
}
|
Reference in New Issue
Block a user