mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-10-06 19:07:50 +00:00
add wildcard checks to checkHeaderAcceptJSON()
This commit is contained in:
parent
c1f11d40e4
commit
9d3332929d
1 changed files with 8 additions and 8 deletions
|
|
@ -258,19 +258,19 @@ func (h *Handler) handleHome(w http.ResponseWriter, r *http.Request) {
|
|||
http.Error(w, "Welcome. Pilosa is running. Visit https://www.pilosa.com/docs/ for more information.", http.StatusNotFound)
|
||||
}
|
||||
|
||||
// checkHeaderAcceptJSON returns true if one or more Accept
|
||||
// headers are present, but none of them are "application/json"
|
||||
// (or any matching wildcard). Otherwise returns false.
|
||||
func checkHeaderAcceptJSON(header http.Header) bool {
|
||||
v, found := header["Accept"]
|
||||
sendError := false
|
||||
if found {
|
||||
sendError = true
|
||||
if v, found := header["Accept"]; found {
|
||||
for _, v := range v {
|
||||
if v == "application/json" {
|
||||
sendError = false
|
||||
|
||||
if v == "application/json" || v == "*/*" || v == "*/json" || v == "application/*" {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
return sendError
|
||||
return false
|
||||
}
|
||||
|
||||
// handleGetSchema handles GET /schema requests.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue