Documentation
¶
Overview ¶
Package rest provides HTTP types and primitives for REST requests validation and response handling.
Index ¶
- Variables
- func WriteErrorResponse(w http.ResponseWriter, status int, err string)
- type BaseReq
- type CommitTxProof
- type ErrorResponse
- type GasEstimateResponse
- func (*GasEstimateResponse) Descriptor() ([]byte, []int)
- func (m *GasEstimateResponse) GetGasEstimate() uint64
- func (m *GasEstimateResponse) Marshal() (dAtA []byte, err error)
- func (m *GasEstimateResponse) MarshalTo(dAtA []byte) (int, error)
- func (m *GasEstimateResponse) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (*GasEstimateResponse) ProtoMessage()
- func (m *GasEstimateResponse) Reset()
- func (m *GasEstimateResponse) Size() (n int)
- func (m *GasEstimateResponse) String() string
- func (m *GasEstimateResponse) Unmarshal(dAtA []byte) error
- func (m *GasEstimateResponse) XXX_DiscardUnknown()
- func (m *GasEstimateResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *GasEstimateResponse) XXX_Merge(src proto.Message)
- func (m *GasEstimateResponse) XXX_Size() int
- func (m *GasEstimateResponse) XXX_Unmarshal(b []byte) error
- type Response
- func (*Response) Descriptor() ([]byte, []int)
- func (m *Response) GetResult() []byte
- func (m *Response) Marshal() (dAtA []byte, err error)
- func (m *Response) MarshalTo(dAtA []byte) (int, error)
- func (m *Response) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (*Response) ProtoMessage()
- func (m *Response) Reset()
- func (m *Response) Size() (n int)
- func (m *Response) String() string
- func (m *Response) Unmarshal(dAtA []byte) error
- func (m *Response) XXX_DiscardUnknown()
- func (m *Response) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *Response) XXX_Merge(src proto.Message)
- func (m *Response) XXX_Size() int
- func (m *Response) XXX_Unmarshal(b []byte) error
- type SideTxProof
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func WriteErrorResponse ¶
func WriteErrorResponse(w http.ResponseWriter, status int, err string)
WriteErrorResponse prepares and writes an HTTP error given a status code and an error message.
Types ¶
type BaseReq ¶
type BaseReq struct {
From string `json:"from"`
Memo string `json:"memo"`
ChainID string `json:"chain_id"`
AccountNumber uint64 `json:"account_number"`
Sequence uint64 `json:"sequence"`
Fees sdk.Coins `json:"fees"`
GasPrices sdk.DecCoins `json:"gas_prices"`
Gas string `json:"gas"`
GasAdjustment string `json:"gas_adjustment"`
Simulate bool `json:"simulate"`
}
BaseReq defines a structure that can be embedded in other request structures that all share common "base" fields.
func NewBaseReq ¶
func NewBaseReq( from, memo, chainID string, gas, gasAdjustment string, accNumber, seq uint64, fees sdk.Coins, gasPrices sdk.DecCoins, simulate bool, ) BaseReq
NewBaseReq creates a new basic request instance and sanitizes its values
func (BaseReq) ValidateBasic ¶
func (br BaseReq) ValidateBasic(w http.ResponseWriter) bool
ValidateBasic performs basic validation of a BaseReq. If custom validation logic is needed, the implementing request handler should perform those checks manually.
type CommitTxProof ¶
type CommitTxProof struct {
Vote string `json:"vote"`
Sigs string `json:"sigs"`
Tx string `json:"tx"`
Proof string `json:"proof"`
}
CommitTxProof commit tx proof
type ErrorResponse ¶
ErrorResponse defines the attributes of a JSON error response.
func NewErrorResponse ¶
func NewErrorResponse(code int, err string) ErrorResponse
NewErrorResponse creates a new ErrorResponse instance.
type GasEstimateResponse ¶
type GasEstimateResponse struct {
// Estimated gas units required for the transaction.
GasEstimate uint64 `protobuf:"varint,1,opt,name=gas_estimate,json=gasEstimate,proto3" json:"gas_estimate,omitempty"`
}
GasEstimateResponse contains gas estimation for a transaction.
func (*GasEstimateResponse) Descriptor ¶
func (*GasEstimateResponse) Descriptor() ([]byte, []int)
func (*GasEstimateResponse) GetGasEstimate ¶
func (m *GasEstimateResponse) GetGasEstimate() uint64
func (*GasEstimateResponse) Marshal ¶
func (m *GasEstimateResponse) Marshal() (dAtA []byte, err error)
func (*GasEstimateResponse) MarshalTo ¶
func (m *GasEstimateResponse) MarshalTo(dAtA []byte) (int, error)
func (*GasEstimateResponse) MarshalToSizedBuffer ¶
func (m *GasEstimateResponse) MarshalToSizedBuffer(dAtA []byte) (int, error)
func (*GasEstimateResponse) ProtoMessage ¶
func (*GasEstimateResponse) ProtoMessage()
func (*GasEstimateResponse) Reset ¶
func (m *GasEstimateResponse) Reset()
func (*GasEstimateResponse) Size ¶
func (m *GasEstimateResponse) Size() (n int)
func (*GasEstimateResponse) String ¶
func (m *GasEstimateResponse) String() string
func (*GasEstimateResponse) Unmarshal ¶
func (m *GasEstimateResponse) Unmarshal(dAtA []byte) error
func (*GasEstimateResponse) XXX_DiscardUnknown ¶
func (m *GasEstimateResponse) XXX_DiscardUnknown()
func (*GasEstimateResponse) XXX_Marshal ¶
func (m *GasEstimateResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*GasEstimateResponse) XXX_Merge ¶
func (m *GasEstimateResponse) XXX_Merge(src proto.Message)
func (*GasEstimateResponse) XXX_Size ¶
func (m *GasEstimateResponse) XXX_Size() int
func (*GasEstimateResponse) XXX_Unmarshal ¶
func (m *GasEstimateResponse) XXX_Unmarshal(b []byte) error
type Response ¶
type Response struct {
// Raw result data.
Result []byte `protobuf:"bytes,1,opt,name=result,proto3" json:"result,omitempty"`
}
Response is a generic REST API response wrapper.
func (*Response) Descriptor ¶
func (*Response) MarshalToSizedBuffer ¶
func (*Response) ProtoMessage ¶
func (*Response) ProtoMessage()
func (*Response) XXX_DiscardUnknown ¶
func (m *Response) XXX_DiscardUnknown()
func (*Response) XXX_Marshal ¶
func (*Response) XXX_Unmarshal ¶
type SideTxProof ¶
type SideTxProof struct {
Sigs [][3]string `json:"sigs"`
Tx string `json:"tx"`
Data string `json:"data"`
}
SideTxProof side-tx proof