rest

package
v0.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 23, 2026 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Package rest provides HTTP types and primitives for REST requests validation and response handling.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidLengthRest        = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowRest          = fmt.Errorf("proto: integer overflow")
	ErrUnexpectedEndOfGroupRest = fmt.Errorf("proto: unexpected end of group")
)

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) Sanitize

func (br BaseReq) Sanitize() BaseReq

Sanitize performs basic sanitization on a BaseReq object.

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

type ErrorResponse struct {
	Code  int    `json:"code,omitempty"`
	Error string `json:"error"`
}

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) Descriptor() ([]byte, []int)

func (*Response) GetResult

func (m *Response) GetResult() []byte

func (*Response) Marshal

func (m *Response) Marshal() (dAtA []byte, err error)

func (*Response) MarshalTo

func (m *Response) MarshalTo(dAtA []byte) (int, error)

func (*Response) MarshalToSizedBuffer

func (m *Response) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*Response) ProtoMessage

func (*Response) ProtoMessage()

func (*Response) Reset

func (m *Response) Reset()

func (*Response) Size

func (m *Response) Size() (n int)

func (*Response) String

func (m *Response) String() string

func (*Response) Unmarshal

func (m *Response) Unmarshal(dAtA []byte) error

func (*Response) XXX_DiscardUnknown

func (m *Response) XXX_DiscardUnknown()

func (*Response) XXX_Marshal

func (m *Response) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Response) XXX_Merge

func (m *Response) XXX_Merge(src proto.Message)

func (*Response) XXX_Size

func (m *Response) XXX_Size() int

func (*Response) XXX_Unmarshal

func (m *Response) XXX_Unmarshal(b []byte) error

type SideTxProof

type SideTxProof struct {
	Sigs [][3]string `json:"sigs"`
	Tx   string      `json:"tx"`
	Data string      `json:"data"`
}

SideTxProof side-tx proof

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL