Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

Set header response after body marshal succeeds

天舟34e7fcfdd39b
diff --git a/backend/server/auth.go b/backend/server/auth.go
index d163e3a2b4..7ee352f1c9 100644
--- a/backend/server/auth.go
+++ b/backend/server/auth.go
@@ -37,11 +37,11 @@ func (s *Server) registerAuthRoutes(g *echo.Group) {
return echo.NewHTTPError(http.StatusInternalServerError, "Failed to generate access token.").SetInternal(err)
}
- c.Response().Header().Set(echo.HeaderContentType, echo.MIMEApplicationJSONCharsetUTF8)
- c.Response().WriteHeader(http.StatusOK)
if err := jsonapi.MarshalPayload(c.Response().Writer, user); err != nil {
return echo.NewHTTPError(http.StatusInternalServerError, "Failed to marshal login response.").SetInternal(err)
}
+ c.Response().Header().Set(echo.HeaderContentType, echo.MIMEApplicationJSONCharsetUTF8)
+ c.Response().WriteHeader(http.StatusOK)
return nil
})
@@ -78,11 +78,11 @@ func (s *Server) registerAuthRoutes(g *echo.Group) {
return echo.NewHTTPError(http.StatusInternalServerError, "Failed to generate access token.").SetInternal(err)
}
- c.Response().Header().Set(echo.HeaderContentType, echo.MIMEApplicationJSONCharsetUTF8)
- c.Response().WriteHeader(http.StatusOK)
if err := jsonapi.MarshalPayload(c.Response().Writer, user); err != nil {
return echo.NewHTTPError(http.StatusInternalServerError, "Failed to marshal signup response.").SetInternal(err)
}
+ c.Response().Header().Set(echo.HeaderContentType, echo.MIMEApplicationJSONCharsetUTF8)
+ c.Response().WriteHeader(http.StatusOK)
return nil
})
diff --git a/backend/server/principal.go b/backend/server/principal.go
index 3b6e2c43e4..9d9cc775a4 100644
--- a/backend/server/principal.go
+++ b/backend/server/principal.go
@@ -32,11 +32,11 @@ func (s *Server) registerPrincipalRoutes(g *echo.Group) {
return echo.NewHTTPError(http.StatusInternalServerError, "Failed to create principal.").SetInternal(err)
}
- c.Response().Header().Set(echo.HeaderContentType, echo.MIMEApplicationJSONCharsetUTF8)
- c.Response().WriteHeader(http.StatusOK)
if err := jsonapi.MarshalPayload(c.Response().Writer, principal); err != nil {
return echo.NewHTTPError(http.StatusInternalServerError, "Failed to marshal create principal response").SetInternal(err)
}
+ c.Response().Header().Set(echo.HeaderContentType, echo.MIMEApplicationJSONCharsetUTF8)
+ c.Response().WriteHeader(http.StatusOK)
return nil
})
@@ -47,11 +47,11 @@ func (s *Server) registerPrincipalRoutes(g *echo.Group) {
return echo.NewHTTPError(http.StatusInternalServerError, "Failed to fetch principal list.").SetInternal(err)
}
- c.Response().Header().Set(echo.HeaderContentType, echo.MIMEApplicationJSONCharsetUTF8)
- c.Response().WriteHeader(http.StatusOK)
if err := jsonapi.MarshalPayload(c.Response().Writer, list); err != nil {
return echo.NewHTTPError(http.StatusInternalServerError, "Failed to marshal principal list response.").SetInternal(err)
}
+ c.Response().Header().Set(echo.HeaderContentType, echo.MIMEApplicationJSONCharsetUTF8)
+ c.Response().WriteHeader(http.StatusOK)
return nil
})
@@ -70,11 +70,11 @@ func (s *Server) registerPrincipalRoutes(g *echo.Group) {
return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to fetch principal ID: %v.", id)).SetInternal(err)
}
- c.Response().Header().Set(echo.HeaderContentType, echo.MIMEApplicationJSONCharsetUTF8)
- c.Response().WriteHeader(http.StatusOK)
if err := jsonapi.MarshalPayload(c.Response().Writer, principal); err != nil {
return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to marshal principal ID response: %v.", id)).SetInternal(err)
}
+ c.Response().Header().Set(echo.HeaderContentType, echo.MIMEApplicationJSONCharsetUTF8)
+ c.Response().WriteHeader(http.StatusOK)
return nil
})
@@ -98,11 +98,11 @@ func (s *Server) registerPrincipalRoutes(g *echo.Group) {
return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to patch principal ID: %v.", id)).SetInternal(err)
}
- c.Response().Header().Set(echo.HeaderContentType, echo.MIMEApplicationJSONCharsetUTF8)
- c.Response().WriteHeader(http.StatusOK)
if err := jsonapi.MarshalPayload(c.Response().Writer, principal); err != nil {
return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to marshal principal ID response: %v.", id)).SetInternal(err)
}
+ c.Response().Header().Set(echo.HeaderContentType, echo.MIMEApplicationJSONCharsetUTF8)
+ c.Response().WriteHeader(http.StatusOK)
return nil
})