Skip to content

Commit

Permalink
Revert "internal/rest: Update Render and pass request"
Browse files Browse the repository at this point in the history
This reverts commit bda756d.

Signed-off-by: Julian Pelizäus <[email protected]>
  • Loading branch information
roosterfish committed Nov 6, 2024
1 parent f2dfccc commit 331dd58
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions internal/rest/rest.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func handleAPIRequest(action rest.EndpointAction, state state.State, w http.Resp
}

if resp != nil {
err := resp.Render(w, r)
err := resp.Render(w)
if err != nil {
return response.InternalError(err)
}
Expand Down Expand Up @@ -194,7 +194,7 @@ func HandleEndpoint(state state.State, mux *mux.Router, version string, e rest.E

intState, err := internalState.ToInternal(state)
if err != nil {
err := response.BadRequest(err).Render(w, r)
err := response.BadRequest(err).Render(w)
if err != nil {
logger.Error("Failed to write HTTP response", logger.Ctx{"url": r.URL, "err": err})
}
Expand All @@ -204,7 +204,7 @@ func HandleEndpoint(state state.State, mux *mux.Router, version string, e rest.E

// Return Unavailable Error (503) if daemon is shutting down, except for endpoints with AllowedDuringShutdown.
if intState.Context.Err() == context.Canceled && !e.AllowedDuringShutdown {
err := response.Unavailable(fmt.Errorf("Daemon is shutting down")).Render(w, r)
err := response.Unavailable(fmt.Errorf("Daemon is shutting down")).Render(w)
if err != nil {
logger.Error("Failed to write HTTP response", logger.Ctx{"url": r.URL, "err": err})
}
Expand All @@ -215,7 +215,7 @@ func HandleEndpoint(state state.State, mux *mux.Router, version string, e rest.E
if !e.AllowedBeforeInit {
err := state.Database().IsOpen(r.Context())
if err != nil {
err := response.SmartError(err).Render(w, r)
err := response.SmartError(err).Render(w)
if err != nil {
logger.Error("Failed to write HTTP response", logger.Ctx{"url": r.URL, "err": err})
}
Expand Down Expand Up @@ -259,9 +259,9 @@ func HandleEndpoint(state state.State, mux *mux.Router, version string, e rest.E
// we can ensure that the connection wasn't yet hijacked and the actual error
// can be safely returned to the caller.
if e.Path != "database" || (e.Path == "database" && resp != response.EmptySyncResponse) {
err := resp.Render(w, r)
err := resp.Render(w)
if err != nil {
err := response.InternalError(err).Render(w, r)
err := response.InternalError(err).Render(w)
if err != nil {
logger.Error("Failed writing error for HTTP response", logger.Ctx{"url": url, "error": err})
}
Expand Down

0 comments on commit 331dd58

Please sign in to comment.