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) {
|
func sendJSONError(w http.ResponseWriter, err error) {
|
||||||
|
log.Println("ERROR: ", err)
|
||||||
switch e := err.(type) {
|
switch e := err.(type) {
|
||||||
case bsync.SyncError:
|
case bsync.SyncError:
|
||||||
sendJSON(w, e.StatusCode, e.Payload)
|
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 {
|
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)
|
sendJSONError(w, bsync.RequiredDataNotFoundError)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue