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")