Relax content-type checking. Log errors.
This commit is contained in:
parent
9c92ba5c7f
commit
f18da80e0d
|
@ -63,6 +63,7 @@ func sendJSONOk(w http.ResponseWriter, data interface{}) {
|
|||
}
|
||||
|
||||
func sendJSONError(w http.ResponseWriter, err error) {
|
||||
log.Println("ERROR: ", err)
|
||||
switch e := err.(type) {
|
||||
case bsync.SyncError:
|
||||
sendJSON(w, e.StatusCode, e.Payload)
|
||||
|
@ -89,7 +90,8 @@ func info(w http.ResponseWriter, req *http.Request) {
|
|||
}
|
||||
|
||||
func ensureJSONRequest(w http.ResponseWriter, req *http.Request) bool {
|
||||
if strings.ToLower(req.Header["Content-Type"][0]) != "application/json" {
|
||||
contentType := strings.Split(strings.ToLower(req.Header["Content-Type"][0]), ";")[0]
|
||||
if contentType != "application/json" {
|
||||
sendJSONError(w, bsync.RequiredDataNotFoundError)
|
||||
return false
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue