Documentation ¶
Index ¶
- Constants
- func CheckBadRequestError(w http.ResponseWriter, err error) bool
- func CheckError(w http.ResponseWriter, status int, err error) bool
- func CheckInternalServerError(w http.ResponseWriter, err error) bool
- func ParseQueryHeightOrReturnBadRequest(w http.ResponseWriter, clientCtx client.Context, r *http.Request) (client.Context, bool)
- func PostProcessResponse(w http.ResponseWriter, ctx client.Context, resp interface{})
- func RegisterRoutes(clientCtx client.Context, rtr *mux.Router)
- func WithHTTPDeprecationHeaders(r *mux.Router) *mux.Router
- func WriteErrorResponse(w http.ResponseWriter, status int, err string)
- type ErrorResponse
- type ResponseWithHeight
Constants ¶
const DeprecationURL = "https://docs.cosmos.network/master/migrations/rest.html"
DeprecationURL is the URL for migrating deprecated REST endpoints to newer ones. TODO Switch to `/` (not `/master`) once v0.40 docs are deployed. https://github.com/cosmos/cosmos-sdk/issues/8019
Variables ¶
This section is empty.
Functions ¶
func CheckBadRequestError ¶ added in v1.0.4
func CheckBadRequestError(w http.ResponseWriter, err error) bool
CheckBadRequestError attaches an error message to an HTTP 400 BAD REQUEST response. Returns false when err is nil; it returns true otherwise.
func CheckError ¶ added in v1.0.4
func CheckError(w http.ResponseWriter, status int, err error) bool
CheckError takes care of writing an error response if err is not nil. Returns false when err is nil; it returns true otherwise.
func CheckInternalServerError ¶ added in v1.0.4
func CheckInternalServerError(w http.ResponseWriter, err error) bool
CheckInternalServerError attaches an error message to an HTTP 500 INTERNAL SERVER ERROR response. Returns false when err is nil; it returns true otherwise.
func ParseQueryHeightOrReturnBadRequest ¶ added in v1.0.4
func ParseQueryHeightOrReturnBadRequest(w http.ResponseWriter, clientCtx client.Context, r *http.Request) (client.Context, bool)
ParseQueryHeightOrReturnBadRequest sets the height to execute a query if set by the http request. It returns false if there was an error parsing the height.
func PostProcessResponse ¶ added in v1.0.4
func PostProcessResponse(w http.ResponseWriter, ctx client.Context, resp interface{})
PostProcessResponse performs post processing for a REST response. The result returned to clients will contain two fields, the height at which the resource was queried at and the original result.
func RegisterRoutes ¶
RegisterRoutes registers minting module REST handlers on the provided router.
func WithHTTPDeprecationHeaders ¶ added in v1.0.4
func WriteErrorResponse ¶ added in v1.0.4
func WriteErrorResponse(w http.ResponseWriter, status int, err string)
WriteErrorResponse prepares and writes a HTTP error given a status code and an error message.
Types ¶
type ErrorResponse ¶ added in v1.0.4
ErrorResponse defines the attributes of a JSON error response.
func NewErrorResponse ¶ added in v1.0.4
func NewErrorResponse(code int, err string) ErrorResponse
NewErrorResponse creates a new ErrorResponse instance.
type ResponseWithHeight ¶ added in v1.0.4
type ResponseWithHeight struct { Height int64 `json:"height"` Result json.RawMessage `json:"result"` }
ResponseWithHeight defines a response object type that wraps an original response with a height.
func NewResponseWithHeight ¶ added in v1.0.4
func NewResponseWithHeight(height int64, result json.RawMessage) ResponseWithHeight
NewResponseWithHeight creates a new ResponseWithHeight instance