From 6debf95e348c0b255cd682d2ea64bfd196203b9a Mon Sep 17 00:00:00 2001 From: Vasiliy Tolstov Date: Wed, 3 Mar 2021 16:53:36 +0300 Subject: [PATCH] fix content type for fatal error Signed-off-by: Vasiliy Tolstov --- rpc.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rpc.go b/rpc.go index 53f7174..8a3156f 100644 --- a/rpc.go +++ b/rpc.go @@ -428,6 +428,9 @@ func requestPayload(r *http.Request) ([]byte, error) { func writeError(w http.ResponseWriter, r *http.Request, err error) { ce := errors.Parse(err.Error()) + // response content type + w.Header().Set("Content-Type", "application/json") + switch ce.Code { case 0: // assuming it's totally screwed @@ -440,9 +443,6 @@ func writeError(w http.ResponseWriter, r *http.Request, err error) { w.WriteHeader(int(ce.Code)) } - // response content type - w.Header().Set("Content-Type", "application/json") - // Set trailers if strings.Contains(r.Header.Get("Content-Type"), "application/grpc") { w.Header().Set("Trailer", "grpc-status")