|
|
@ -23,6 +23,7 @@ import ( |
|
|
|
"fmt" |
|
|
|
"fmt" |
|
|
|
"io" |
|
|
|
"io" |
|
|
|
"io/ioutil" |
|
|
|
"io/ioutil" |
|
|
|
|
|
|
|
"mime" |
|
|
|
"net" |
|
|
|
"net" |
|
|
|
"net/http" |
|
|
|
"net/http" |
|
|
|
"sync" |
|
|
|
"sync" |
|
|
@ -151,6 +152,16 @@ func (srv *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) { |
|
|
|
http.StatusRequestEntityTooLarge) |
|
|
|
http.StatusRequestEntityTooLarge) |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ct := r.Header.Get("content-type") |
|
|
|
|
|
|
|
mt, _, err := mime.ParseMediaType(ct) |
|
|
|
|
|
|
|
if err != nil || mt != "application/json" { |
|
|
|
|
|
|
|
http.Error(w, |
|
|
|
|
|
|
|
"invalid content type, only application/json is supported", |
|
|
|
|
|
|
|
http.StatusUnsupportedMediaType) |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
w.Header().Set("content-type", "application/json") |
|
|
|
w.Header().Set("content-type", "application/json") |
|
|
|
|
|
|
|
|
|
|
|
// create a codec that reads direct from the request body until
|
|
|
|
// create a codec that reads direct from the request body until
|
|
|
|