diff --git a/examples/shipping/booking/transport.go b/examples/shipping/booking/transport.go index 6592a9d..8cf11a2 100644 --- a/examples/shipping/booking/transport.go +++ b/examples/shipping/booking/transport.go @@ -179,6 +179,7 @@ // encode errors from business-logic func encodeError(_ context.Context, err error, w http.ResponseWriter) { + w.Header().Set("Content-Type", "application/json; charset=utf-8") switch err { case cargo.ErrUnknown: w.WriteHeader(http.StatusNotFound) @@ -187,7 +188,6 @@ default: w.WriteHeader(http.StatusInternalServerError) } - w.Header().Set("Content-Type", "application/json; charset=utf-8") json.NewEncoder(w).Encode(map[string]interface{}{ "error": err.Error(), }) diff --git a/examples/shipping/handling/transport.go b/examples/shipping/handling/transport.go index 065bda1..0e21365 100644 --- a/examples/shipping/handling/transport.go +++ b/examples/shipping/handling/transport.go @@ -85,6 +85,7 @@ // encode errors from business-logic func encodeError(_ context.Context, err error, w http.ResponseWriter) { + w.Header().Set("Content-Type", "application/json; charset=utf-8") switch err { case cargo.ErrUnknown: w.WriteHeader(http.StatusNotFound) @@ -93,7 +94,6 @@ default: w.WriteHeader(http.StatusInternalServerError) } - w.Header().Set("Content-Type", "application/json; charset=utf-8") json.NewEncoder(w).Encode(map[string]interface{}{ "error": err.Error(), }) diff --git a/examples/shipping/tracking/transport.go b/examples/shipping/tracking/transport.go index 13d17f2..32db971 100644 --- a/examples/shipping/tracking/transport.go +++ b/examples/shipping/tracking/transport.go @@ -59,6 +59,7 @@ // encode errors from business-logic func encodeError(_ context.Context, err error, w http.ResponseWriter) { + w.Header().Set("Content-Type", "application/json; charset=utf-8") switch err { case cargo.ErrUnknown: w.WriteHeader(http.StatusNotFound) @@ -67,7 +68,6 @@ default: w.WriteHeader(http.StatusInternalServerError) } - w.Header().Set("Content-Type", "application/json; charset=utf-8") json.NewEncoder(w).Encode(map[string]interface{}{ "error": err.Error(), })