{"modulePath":"github.com/parallelcointeam/exploder","version":"v2.1.3+incompatible","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package middleware\n\n## Constants\n\n```go\nconst (\n\tCtxAddress contextKey\n\n\tCtxBlockDate\n\tCtxLimit\n)\n```\n\n## Functions\n\n```go\nfunc APIDirectory(w http.ResponseWriter, r *http.Request)\n```\nAPIDirectory is the actual handler used with apiDocs (e.g. mux.With(apiDocs(mux)).HandleFunc(\"/help\", APIDirectory))\n\n```go\nfunc AddressPathCtx(next http.Handler) http.Handler\n```\nAddressPathCtx returns a http.HandlerFunc that embeds the value at the url part {address} into the request context.\n\n```go\nfunc AddressPostCtx(next http.Handler) http.Handler\n```\nAddressPostCtx returns a http.HandlerFunc that embeds the {addrs} value in the post request into the request context.\n\n```go\nfunc BlockDateQueryCtx(next http.Handler) http.Handler\n```\nBlockDateQueryCtx returns a http.Handlerfunc that embeds the {blockdate, limit} value in the request into the request context.\n\n```go\nfunc BlockHashLatestCtx(r *http.Request, source DataSource) context.Context\n```\nBlockHashLatestCtx embeds the current block height and hash into a request context.\n\n```go\nfunc BlockHashPathAndIndexCtx(r *http.Request, source DataSource) context.Context\n```\nBlockHashPathAndIndexCtx embeds the value at the url part {blockhash}, and the corresponding block index, into a request context.\n\n```go\nfunc BlockHashPathCtx(next http.Handler) http.Handler\n```\nBlockHashPathCtx returns a http.HandlerFunc that embeds the value at the url part {blockhash} into the request context.\n\n```go\nfunc BlockIndex0PathCtx(next http.Handler) http.Handler\n```\nBlockIndex0PathCtx returns a http.HandlerFunc that embeds the value at the url part {idx0} into the request context.\n\n```go\nfunc BlockIndexLatestCtx(r *http.Request, source DataSource) context.Context\n```\nBlockIndexLatestCtx embeds the current block height into a request context.\n\n```go\nfunc BlockIndexOrHashPathCtx(next http.Handler) http.Handler\n```\nBlockIndexOrHashPathCtx returns a http.HandlerFunc that embeds the value at the url part {idxorhash} into the request context.\n\n```go\nfunc BlockIndexPathCtx(next http.Handler) http.Handler\n```\nBlockIndexPathCtx returns a http.HandlerFunc that embeds the value at the url part {idx} into the request context.\n\n```go\nfunc BlockStepPathCtx(next http.Handler) http.Handler\n```\nBlockStepPathCtx returns a http.HandlerFunc that embeds the value at the url part {step} into the request context.\n\n```go\nfunc CacheControl(maxAge int64) func(http.Handler) http.Handler\n```\nCacheControl creates a new middleware to set the HTTP response header with \"Cache-Control: max-age=maxAge\" where maxAge is in seconds.\n\n```go\nfunc DisableLog()\n```\nDisableLog disables all library log output.  Logging output is disabled by default until UseLogger is called.\n\n```go\nfunc GetAddressCtx(r *http.Request) string\n```\nGetAddressCtx retrieves the ctxAddress data from the request context. If not set, the return value is an empty string.\n\n```go\nfunc GetBlockDateCtx(r *http.Request) string\n```\nGetBlockDateCtx retrieves the ctxBlockDate data from the request context. If not set, the return value is an empty string.\n\n```go\nfunc GetBlockHashCtx(r *http.Request) string\n```\nGetBlockHashCtx retrieves the ctxBlockHash data from the request context. If not set, the return value is an empty string.\n\n```go\nfunc GetBlockHeightCtx(r *http.Request, source DataSource) int64\n```\nGetBlockHeightCtx returns the block height for the block index or hash specified on the URL path.\n\n```go\nfunc GetBlockIndex0Ctx(r *http.Request) int\n```\nGetBlockStepCtx retrieves the ctxBlockIndex0 data from the request context. If not set, the return value is -1.\n\n```go\nfunc GetBlockIndexCtx(r *http.Request) int\n```\nGetBlockIndexCtx retrieves the ctxBlockIndex data from the request context. If not set, the return -1.\n\n```go\nfunc GetBlockStepCtx(r *http.Request) int\n```\nGetBlockStepCtx retrieves the ctxBlockStep data from the request context. If not set, the return value is -1.\n\n```go\nfunc GetCountCtx(r *http.Request) int\n```\nGetCountCtx retrieves the ctxCount data (\"to\") URL path element from the request context. If not set, the return value is 20. TODO: rename this function.\n\n```go\nfunc GetLatestVoteVersionCtx(r *http.Request) int\n```\nGetLatestVoteVersionCtx attempts to retrieve the latest stake version embedded in the request context.\n\n```go\nfunc GetMCtx(r *http.Request) int\n```\nGetMCtx retrieves the ctxM data from the request context. If not set, the return value is -1.\n\n```go\nfunc GetNCtx(r *http.Request) int\n```\nGetNCtx retrieves the ctxN data from the request context. If not set, the return value is -1.\n\n```go\nfunc GetOffsetCtx(r *http.Request) int\n```\nGetCountCtx retrieves the ctxOffset data (\"from\") from the request context. If not set, the return value is 0. TODO: rename this function.\n\n```go\nfunc GetRawHexTx(r *http.Request) string\n```\nGetRawHexTx retrieves the ctxRawHexTx data from the request context. If not set, the return value is an empty string.\n\n```go\nfunc GetStatusInfoCtx(r *http.Request) string\n```\nGetStatusInfoCtx retrieves the ctxGetStatus data (\"q\" POST form data) from the request context. If not set, the return value is an empty string.\n\n```go\nfunc GetTxIDCtx(r *http.Request) string\n```\nGetTxIDCtx retrieves the ctxTxHash data from the request context. If not set, the return value is an empty string.\n\n```go\nfunc GetTxIOIndexCtx(r *http.Request) int\n```\nGetTxIOIndexCtx retrieves the ctxTxInOutIndex data from the request context. If not set, the return value is -1.\n\n```go\nfunc GetTxnsCtx(r *http.Request) []string\n```\nGetTxnsCtx retrieves the ctxTxns data from the request context. If not set, the return value is an empty string slice.\n\n```go\nfunc MPathCtx(next http.Handler) http.Handler\n```\nMPathCtx returns a http.HandlerFunc that embeds the value at the url part {M} into the request context\n\n```go\nfunc NPathCtx(next http.Handler) http.Handler\n```\nNPathCtx returns a http.HandlerFunc that embeds the value at the url part {N} into the request context.\n\n```go\nfunc PaginationCtx(next http.Handler) http.Handler\n```\nPaginationCtx returns a http.Handlerfunc that embeds the {to,from} value in the request into the request context.\n\n```go\nfunc PostTxnsCtx(next http.Handler) http.Handler\n```\nPostTxnsCtx extract transaction IDs from the POST body\n\n```go\nfunc SearchPathCtx(next http.Handler) http.Handler\n```\nSearchPathCtx returns a http.HandlerFunc that embeds the value at the url part {search} into the request context (Still need this for the error page) TODO: make new error system\n\n```go\nfunc StakeVersionLatestCtx(r *http.Request, stakeVerFun StakeVersionsLatest) context.Context\n```\nStakeVersionLatestCtx embeds the specified StakeVersionsLatest function into a request context.\n\n```go\nfunc StatusCtx(r *http.Request, status apitypes.Status) context.Context\n```\nStatusCtx embeds the specified apitypes.Status into a request context.\n\n```go\nfunc StatusInfoCtx(r *http.Request, source DataSource) context.Context\n```\nStatusInfoCtx embeds the best block index and the POST form data for parameter \"q\" into a request context.\n\n```go\nfunc TransactionHashCtx(next http.Handler) http.Handler\n```\nTransactionHashCtx returns a http.HandlerFunc that embeds the value at the url part {txid} into the request context.\n\n```go\nfunc TransactionIOIndexCtx(next http.Handler) http.Handler\n```\nTransactionIOIndexCtx returns a http.HandlerFunc that embeds the value at the url part {txinoutindex} into the request context\n\n```go\nfunc TransactionsCtx(next http.Handler) http.Handler\n```\nTransactionsCtx returns a http.Handlerfunc that embeds the {address, blockhash} value in the request into the request context.\n\n```go\nfunc UseLogger(logger slog.Logger)\n```\nUseLogger uses a specified Logger to output package logging info.\n\n```go\nfunc ValidateTxnsPostCtx(next http.Handler) http.Handler\n```\nValidateTxnsPostCtx will confirm Post content length is valid.\n\n## Types\n\n```go\ntype DataSource interface {\n\tGetHeight() int\n\tGetBlockHeight(hash string) (int64, error)\n\tGetBlockHash(idx int64) (string, error)\n}\n```\n\n```go\ntype StakeVersionsLatest func() (*dcrjson.StakeVersions, error)\n```\n\n","path":"github.com/parallelcointeam/exploder/middleware","name":"middleware","synopsis":"","isRedistributable":true}
