add content type handlers

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
2021-04-13 23:42:33 +03:00
parent 622a79bd06
commit bb763c71b5
5 changed files with 45 additions and 53 deletions

View File

@@ -74,6 +74,16 @@ func (h *httpServer) ServeHTTP(w http.ResponseWriter, r *http.Request) {
}
}
ct := DefaultContentType
if htype := r.Header.Get("Content-Type"); htype != "" {
ct = htype
}
if ph, ok := h.contentTypeHandlers[strings.Split(ct, ";")[0]]; ok {
ph(w, r)
return
}
ctx := metadata.NewContext(r.Context(), nil)
defer r.Body.Close()
@@ -84,11 +94,6 @@ func (h *httpServer) ServeHTTP(w http.ResponseWriter, r *http.Request) {
return
}
ct := DefaultContentType
if htype := r.Header.Get("Content-Type"); htype != "" {
ct = htype
}
var cf codec.Codec
var err error
switch ct {