Documentation ¶
Index ¶
- Constants
- func APIDirectory(w http.ResponseWriter, r *http.Request)
- func AddressPathCtx(next http.Handler) http.Handler
- func AddressPostCtx(next http.Handler) http.Handler
- func AgendIdCtx(next http.Handler) http.Handler
- func AgendaIdCtx(next http.Handler) http.Handler
- func BlockDateQueryCtx(next http.Handler) http.Handler
- func BlockHashLatestCtx(r *http.Request, source DataSource) context.Context
- func BlockHashPathAndIndexCtx(r *http.Request, source DataSource) context.Context
- func BlockHashPathCtx(next http.Handler) http.Handler
- func BlockIndex0PathCtx(next http.Handler) http.Handler
- func BlockIndexLatestCtx(r *http.Request, source DataSource) context.Context
- func BlockIndexOrHashPathCtx(next http.Handler) http.Handler
- func BlockIndexPathCtx(next http.Handler) http.Handler
- func BlockStepPathCtx(next http.Handler) http.Handler
- func CacheControl(maxAge int64) func(http.Handler) http.Handler
- func ChartGroupingCtx(next http.Handler) http.Handler
- func ChartTypeCtx(next http.Handler) http.Handler
- func DisableLog()
- func ExchangeTokenContext(next http.Handler) http.Handler
- func GetAddressCtx(r *http.Request, activeNetParams *chaincfg.Params, maxAddrs int) ([]string, error)
- func GetAgendaIdCtx(r *http.Request) string
- func GetBlockDateCtx(r *http.Request) string
- func GetBlockHashCtx(r *http.Request) (string, error)
- func GetBlockHeightCtx(r *http.Request, source DataSource) (int64, error)
- func GetBlockIndex0Ctx(r *http.Request) int
- func GetBlockIndexCtx(r *http.Request) int
- func GetBlockStepCtx(r *http.Request) int
- func GetChartGroupingCtx(r *http.Request) string
- func GetChartTypeCtx(r *http.Request) string
- func GetCountCtx(r *http.Request) int
- func GetLatestVoteVersionCtx(r *http.Request) int
- func GetMCtx(r *http.Request) int
- func GetNCtx(r *http.Request) int
- func GetOffsetCtx(r *http.Request) int
- func GetPageNumCtx(r *http.Request) int
- func GetProposalTokenCtx(r *http.Request) string
- func GetRawHexTx(r *http.Request) (string, error)
- func GetStatusInfoCtx(r *http.Request) string
- func GetTpCtx(r *http.Request) string
- func GetTxIDCtx(r *http.Request) (*chainhash.Hash, error)
- func GetTxIOIndexCtx(r *http.Request) int
- func GetTxnsCtx(r *http.Request) ([]*chainhash.Hash, error)
- func MPathCtx(next http.Handler) http.Handler
- func NPathCtx(next http.Handler) http.Handler
- func Next(next http.Handler) http.Handler
- func NoOrigin(next http.Handler) http.Handler
- func OriginalRequestURI(next http.Handler) http.Handler
- func PageNumCtx(next http.Handler) http.Handler
- func PaginationCtx(next http.Handler) http.Handler
- func PostBroadcastTxCtx(next http.Handler) http.Handler
- func PostTxnsCtx(next http.Handler) http.Handler
- func ProposalTokenCtx(next http.Handler) http.Handler
- func RetrieveExchangeTokenCtx(r *http.Request) string
- func RetrieveStickWidthCtx(r *http.Request) string
- func StakeVersionLatestCtx(r *http.Request, stakeVerFun StakeVersionsLatest) context.Context
- func StatusInfoCtx(r *http.Request, source DataSource) context.Context
- func StickWidthContext(next http.Handler) http.Handler
- func TicketPoolCtx(next http.Handler) http.Handler
- func Tollbooth(l *Limiter) func(http.Handler) http.Handler
- func TransactionHashCtx(next http.Handler) http.Handler
- func TransactionIOIndexCtx(next http.Handler) http.Handler
- func TransactionsCtx(next http.Handler) http.Handler
- func UseLogger(logger slog.Logger)
- func ValidateTxnsPostCtx(next http.Handler) http.Handler
- type DataSource
- type Limiter
- type StakeVersionsLatest
Constants ¶
const ( CtxAddress contextKey CtxBlockDate CtxLimit )
These are the keys for different types of values stored in a request context.
Variables ¶
This section is empty.
Functions ¶
func APIDirectory ¶
func APIDirectory(w http.ResponseWriter, r *http.Request)
APIDirectory is the actual handler used with apiDocs (e.g. mux.With(apiDocs(mux)).HandleFunc("/help", APIDirectory))
func AddressPathCtx ¶
AddressPathCtx returns a http.HandlerFunc that embeds the value at the url part {address} into the request context.
func AddressPostCtx ¶
AddressPostCtx returns a http.HandlerFunc that embeds the {addrs} value in the post request into the request context.
func AgendIdCtx ¶
AgendIdCtx returns a http.HandlerFunc that embeds the value at the url part {agendaId} into the request context. This is here for backward compatibility.
func AgendaIdCtx ¶
AgendaIdCtx returns a http.HandlerFunc that embeds the value at the url part {agendaId} into the request context.
func BlockDateQueryCtx ¶
BlockDateQueryCtx returns a http.Handlerfunc that embeds the {blockdate, limit} value in the request into the request context.
func BlockHashLatestCtx ¶
func BlockHashLatestCtx(r *http.Request, source DataSource) context.Context
BlockHashLatestCtx embeds the current block height and hash into a request context.
func BlockHashPathAndIndexCtx ¶
func BlockHashPathAndIndexCtx(r *http.Request, source DataSource) context.Context
BlockHashPathAndIndexCtx embeds the value at the url part {blockhash}, and the corresponding block index, into a request context.
func BlockHashPathCtx ¶
BlockHashPathCtx returns a http.HandlerFunc that embeds the value at the url part {blockhash} into the request context.
func BlockIndex0PathCtx ¶
BlockIndex0PathCtx returns a http.HandlerFunc that embeds the value at the url part {idx0} into the request context.
func BlockIndexLatestCtx ¶
func BlockIndexLatestCtx(r *http.Request, source DataSource) context.Context
BlockIndexLatestCtx embeds the current block height into a request context.
func BlockIndexOrHashPathCtx ¶
BlockIndexOrHashPathCtx returns a http.HandlerFunc that embeds the value at the url part {idxorhash} into the request context.
func BlockIndexPathCtx ¶
BlockIndexPathCtx returns a http.HandlerFunc that embeds the value at the url part {idx} into the request context.
func BlockStepPathCtx ¶
BlockStepPathCtx returns a http.HandlerFunc that embeds the value at the url part {step} into the request context.
func CacheControl ¶
CacheControl creates a new middleware to set the HTTP response header with "Cache-Control: max-age=maxAge" where maxAge is in seconds.
func ChartGroupingCtx ¶
ChartGroupingCtx returns a http.HandlerFunc that embeds the value art the url part {chartgrouping} into the request context.
func ChartTypeCtx ¶
ChartTypeCtx returns a http.HandlerFunc that embeds the value at the url part {charttype} into the request context.
func DisableLog ¶
func DisableLog()
DisableLog disables all library log output. Logging output is disabled by default until UseLogger is called.
func ExchangeTokenContext ¶
ExchangeTokenContext pulls the exchange token from the URL.
func GetAddressCtx ¶
func GetAddressCtx(r *http.Request, activeNetParams *chaincfg.Params, maxAddrs int) ([]string, error)
GetAddressCtx retrieves the CtxAddress data from the request context. If not set, the return value is an empty string. The CtxAddress string data may be a comma-separated list of addresses, subject to the provided maximum number of addresses allowed. Duplicate addresses are removed, but the limit is enforced prior to removal of duplicates.
func GetAgendaIdCtx ¶
GetAgendaIdCtx retrieves the ctxAgendaId data from the request context. If not set, the return value is an empty string.
func GetBlockDateCtx ¶
GetBlockDateCtx retrieves the ctxBlockDate data from the request context. If not set, the return value is an empty string.
func GetBlockHashCtx ¶
GetBlockHashCtx retrieves the ctxBlockHash data from the request context. If not set, the return value is an empty string.
func GetBlockHeightCtx ¶
func GetBlockHeightCtx(r *http.Request, source DataSource) (int64, error)
GetBlockHeightCtx returns the block height for the block index or hash specified on the URL path.
func GetBlockIndex0Ctx ¶
GetBlockIndex0Ctx retrieves the ctxBlockIndex0 data from the request context. If not set, the return value is -1.
func GetBlockIndexCtx ¶
GetBlockIndexCtx retrieves the ctxBlockIndex data from the request context. If not set, the return -1.
func GetBlockStepCtx ¶
GetBlockStepCtx retrieves the ctxBlockStep data from the request context. If not set, the return value is -1.
func GetChartGroupingCtx ¶
GetChartGroupingCtx retrieves the ctxChart data from the request context. If not set, the return value is an empty string.
func GetChartTypeCtx ¶
GetChartTypeCtx retrieves the ctxChart data from the request context. If not set, the return value is an empty string.
func GetCountCtx ¶
GetCountCtx retrieves the ctxCount data ("to") URL path element from the request context. If not set, the return value is 20.
func GetLatestVoteVersionCtx ¶
GetLatestVoteVersionCtx attempts to retrieve the latest stake version embedded in the request context.
func GetMCtx ¶
GetMCtx retrieves the ctxM data from the request context. If not set, the return value is -1.
func GetNCtx ¶
GetNCtx retrieves the ctxN data from the request context. If not set, the return value is -1.
func GetOffsetCtx ¶
GetOffsetCtx retrieves the ctxOffset data ("from") from the request context. If not set, the return value is 0.
func GetPageNumCtx ¶
GetPageNumCtx retrieves the ctxPageNum data ("pageNum") URL path element from the request context. If not set, the return value is 1. The page number must be a postitive integer.
func GetProposalTokenCtx ¶
GetProposalTokenCtx retrieves the ctxProposalToken data from the request context. If the value is not set, an empty string is returned.
func GetRawHexTx ¶
GetRawHexTx retrieves the ctxRawHexTx data from the request context. If not set, the return value is an empty string.
func GetStatusInfoCtx ¶
GetStatusInfoCtx retrieves the ctxGetStatus data ("q" POST form data) from the request context. If not set, the return value is an empty string.
func GetTpCtx ¶
GetTpCtx retrieves the ctxTp data from the request context. If the value is not set, an empty string is returned.
func GetTxIDCtx ¶
GetTxIDCtx retrieves the ctxTxHash data from the request context. If not set, the return value is an empty string.
func GetTxIOIndexCtx ¶
GetTxIOIndexCtx retrieves the ctxTxInOutIndex data from the request context. If not set, the return value is -1.
func GetTxnsCtx ¶
GetTxnsCtx retrieves the ctxTxns data from the request context. If not set, the return value is an empty string slice.
func MPathCtx ¶
MPathCtx returns a http.HandlerFunc that embeds the value at the url part {M} into the request context
func NPathCtx ¶
NPathCtx returns a http.HandlerFunc that embeds the value at the url part {N} into the request context.
func OriginalRequestURI ¶
OriginalRequestURI checks the X-Original-Request-URI HTTP request header for a valid URI, and patches the request URL's Path and RawPath. This may be useful in the event that a reverse proxy maps requests on path A to path B, but the request handler requires the original path A (e.g. generating links relative to path A).
func PageNumCtx ¶
PageNumCtx returns a http.Handlerfunc that embeds the {pageNum} URL query parameter value in the request into the request context.
func PaginationCtx ¶
PaginationCtx returns a http.Handlerfunc that embeds the {to,from} value in the request into the request context.
func PostBroadcastTxCtx ¶
PostBroadcastTxCtx is middleware that checks for parameters given in POST request body of the broadcast transaction endpoint.
func PostTxnsCtx ¶
PostTxnsCtx extract transaction IDs from the POST body
func ProposalTokenCtx ¶
ProposalTokenCtx returns a http.HandlerFunc that embeds the value at the url part {token} into the request context
func RetrieveExchangeTokenCtx ¶
RetrieveExchangeTokenCtx tries to fetch the exchange token from the request context.
func RetrieveStickWidthCtx ¶
RetrieveStickWidthCtx tries to fetch the candlestick width from the request context.
func StakeVersionLatestCtx ¶
func StakeVersionLatestCtx(r *http.Request, stakeVerFun StakeVersionsLatest) context.Context
StakeVersionLatestCtx embeds the specified StakeVersionsLatest function into a request context.
func StatusInfoCtx ¶
func StatusInfoCtx(r *http.Request, source DataSource) context.Context
StatusInfoCtx embeds the best block index and the POST form data for parameter "q" into a request context.
func StickWidthContext ¶
StickWidthContext pulls the bin width from the URL.
func TicketPoolCtx ¶
TicketPoolCtx returns a http.HandlerFunc that embeds the value at the url part {tp} into the request context
func Tollbooth ¶ added in v3.1.0
Tollbooth creates a new rate limiter middleware using the provided Limiter.
func TransactionHashCtx ¶
TransactionHashCtx returns a http.HandlerFunc that embeds the value at the url part {txid} into the request context.
func TransactionIOIndexCtx ¶
TransactionIOIndexCtx returns a http.HandlerFunc that embeds the value at the url part {txinoutindex} into the request context
func TransactionsCtx ¶
TransactionsCtx returns a http.Handlerfunc that embeds the {address, blockhash} value in the request into the request context.
Types ¶
type DataSource ¶
type Limiter ¶ added in v3.1.0
Limiter wraps the tollbooth limiter. Use NewLimiter to create a new Limiter.
func NewLimiter ¶ added in v3.1.0
NewLimiter creates a new Limiter for the given maximum allowed request rate in requests per second (may be fractional).
type StakeVersionsLatest ¶
type StakeVersionsLatest func() (*chainjson.StakeVersions, error)