generalize query response with height (#4573)

Addition to #4536, no longer specific to account queries.
Allows for validator endpoints to return height in the response.

Closes: #4609
This commit is contained in:
colin axner
2019-07-01 17:48:13 +01:00
committed by Alessio Treglia
parent 5d5f0149a4
commit 8d8fd9df1a
13 changed files with 209 additions and 38 deletions
+6 -3
View File
@@ -37,12 +37,13 @@ func queryParamsHandlerFn(cliCtx context.CLIContext) http.HandlerFunc {
return
}
res, _, err := cliCtx.QueryWithData(route, nil)
res, height, err := cliCtx.QueryWithData(route, nil)
if err != nil {
rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
return
}
cliCtx = cliCtx.WithHeight(height)
rest.PostProcessResponse(w, cliCtx, res)
}
}
@@ -56,12 +57,13 @@ func queryInflationHandlerFn(cliCtx context.CLIContext) http.HandlerFunc {
return
}
res, _, err := cliCtx.QueryWithData(route, nil)
res, height, err := cliCtx.QueryWithData(route, nil)
if err != nil {
rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
return
}
cliCtx = cliCtx.WithHeight(height)
rest.PostProcessResponse(w, cliCtx, res)
}
}
@@ -75,12 +77,13 @@ func queryAnnualProvisionsHandlerFn(cliCtx context.CLIContext) http.HandlerFunc
return
}
res, _, err := cliCtx.QueryWithData(route, nil)
res, height, err := cliCtx.QueryWithData(route, nil)
if err != nil {
rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
return
}
cliCtx = cliCtx.WithHeight(height)
rest.PostProcessResponse(w, cliCtx, res)
}
}