From ee6e245835fa0954ab8b6c438c3abdffd6c25e07 Mon Sep 17 00:00:00 2001 From: Aleksandr Tolstikhin Date: Wed, 27 Nov 2024 00:50:30 +0700 Subject: [PATCH 1/2] Replacing of status --- handler.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/handler.go b/handler.go index 7ccc2af..4bcb421 100644 --- a/handler.go +++ b/handler.go @@ -199,8 +199,7 @@ func (h *Server) HTTPHandlerFunc(handler interface{}) (http.HandlerFunc, error) cf, err := h.newCodec(ct) if err != nil { - w.WriteHeader(http.StatusBadRequest) - _, _ = w.Write([]byte(err.Error())) + w.WriteHeader(http.StatusUnsupportedMediaType) return } From 85afe16150d3cf6406df813633ab48778032285c Mon Sep 17 00:00:00 2001 From: Aleksandr Tolstikhin Date: Wed, 27 Nov 2024 04:17:47 +0700 Subject: [PATCH 2/2] Editing Status of request --- handler.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/handler.go b/handler.go index 4bcb421..7fae5eb 100644 --- a/handler.go +++ b/handler.go @@ -311,7 +311,7 @@ func (h *Server) HTTPHandlerFunc(handler interface{}) (http.HandlerFunc, error) } if nct := w.Header().Get(metadata.HeaderContentType); nct != ct { 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 } } @@ -677,7 +677,7 @@ func (h *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) { } if nct := w.Header().Get(metadata.HeaderContentType); nct != ct { 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 } }