Merge pull request '[BUG] если кодек не найден для переданного контент тайма отдавать спец ошибку' (#192) from atolstikhin/micro-server-http:v3 into v3
Reviewed-on: #192
This commit was merged in pull request #192.
	This commit is contained in:
		| @@ -199,8 +199,7 @@ func (h *Server) HTTPHandlerFunc(handler interface{}) (http.HandlerFunc, error) | |||||||
|  |  | ||||||
| 		cf, err := h.newCodec(ct) | 		cf, err := h.newCodec(ct) | ||||||
| 		if err != nil { | 		if err != nil { | ||||||
| 			w.WriteHeader(http.StatusBadRequest) | 			w.WriteHeader(http.StatusUnsupportedMediaType) | ||||||
| 			_, _ = w.Write([]byte(err.Error())) |  | ||||||
| 			return | 			return | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| @@ -312,7 +311,7 @@ func (h *Server) HTTPHandlerFunc(handler interface{}) (http.HandlerFunc, error) | |||||||
| 		} | 		} | ||||||
| 		if nct := w.Header().Get(metadata.HeaderContentType); nct != ct { | 		if nct := w.Header().Get(metadata.HeaderContentType); nct != ct { | ||||||
| 			if cf, err = h.newCodec(nct); err != nil { | 			if cf, err = h.newCodec(nct); err != nil { | ||||||
| 				h.errorHandler(ctx, nil, w, r, err, http.StatusBadRequest) | 				h.errorHandler(ctx, nil, w, r, err, http.StatusInternalServerError) | ||||||
| 				return | 				return | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| @@ -679,7 +678,7 @@ func (h *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) { | |||||||
| 	} | 	} | ||||||
| 	if nct := w.Header().Get(metadata.HeaderContentType); nct != ct { | 	if nct := w.Header().Get(metadata.HeaderContentType); nct != ct { | ||||||
| 		if cf, err = h.newCodec(nct); err != nil { | 		if cf, err = h.newCodec(nct); err != nil { | ||||||
| 			h.errorHandler(ctx, nil, w, r, err, http.StatusBadRequest) | 			h.errorHandler(ctx, nil, w, r, err, http.StatusInternalServerError) | ||||||
| 			return | 			return | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user