Documentation ¶
Overview ¶
Package handlers provides HTTP handlers for different services across the application.
Index ¶
- Constants
- Variables
- func Debug(repoURL, sha1ver, buildtime string) http.Handler
- func HandleHealthReady(w http.ResponseWriter, r *http.Request)
- func IdempotencyHandler(h http.Handler, opts IdempotencyHandlerOptions, store IdempotencyStore) http.Handler
- func Liveness(getLiveness func() (interface{}, error)) http.Handler
- func UseCompress(h http.Handler) http.Handler
- func UseCors(h http.Handler) http.Handler
- func UseIdempotency(h http.Handler, opts IdempotencyHandlerOptions, store IdempotencyStore) http.Handler
- func UseJson(h http.Handler) http.Handler
- func UseLogging(h http.Handler) http.Handler
- type Accounts
- func (s *Accounts) AddNonCustodialAccount() http.Handler
- func (s *Accounts) AddNonCustodialAccountFunc(rw http.ResponseWriter, r *http.Request)
- func (s *Accounts) Create() http.Handler
- func (s *Accounts) CreateFunc(rw http.ResponseWriter, r *http.Request)
- func (s *Accounts) DeleteNonCustodialAccount() http.Handler
- func (s *Accounts) DeleteNonCustodialAccountFunc(rw http.ResponseWriter, r *http.Request)
- func (s *Accounts) Details() http.Handler
- func (s *Accounts) DetailsFunc(rw http.ResponseWriter, r *http.Request)
- func (s *Accounts) List() http.Handler
- func (s *Accounts) ListFunc(rw http.ResponseWriter, r *http.Request)
- func (s *Accounts) SyncAccountKeyCount() http.Handler
- func (s *Accounts) SyncAccountKeyCountFunc(rw http.ResponseWriter, r *http.Request)
- type IdempotencyHandlerOptions
- type IdempotencyStore
- type IdempotencyStoreGorm
- type IdempotencyStoreGormItem
- type IdempotencyStoreLocal
- type IdempotencyStoreRedis
- type IdempotencyStoreType
- type Jobs
- type Ops
- type SyncKeyCountRequest
- type System
- type Templates
- func (s *Templates) AddToken() http.Handler
- func (s *Templates) AddTokenFunc(rw http.ResponseWriter, r *http.Request)
- func (s *Templates) GetToken() http.Handler
- func (s *Templates) GetTokenFunc(rw http.ResponseWriter, r *http.Request)
- func (s *Templates) ListTokens(tType templates.TokenType) http.Handler
- func (s *Templates) MakeListTokensFunc(tType templates.TokenType) http.HandlerFunc
- func (s *Templates) RemoveToken() http.Handler
- func (s *Templates) RemoveTokenFunc(rw http.ResponseWriter, r *http.Request)
- type Tokens
- func (s *Tokens) AccountTokens(tType templates.TokenType) http.Handler
- func (s *Tokens) CreateWithdrawal() http.Handler
- func (s *Tokens) CreateWithdrawalFunc(rw http.ResponseWriter, r *http.Request)
- func (s *Tokens) Details() http.Handler
- func (s *Tokens) DetailsFunc(rw http.ResponseWriter, r *http.Request)
- func (s *Tokens) GetDeposit() http.Handler
- func (s *Tokens) GetDepositFunc(rw http.ResponseWriter, r *http.Request)
- func (s *Tokens) GetWithdrawal() http.Handler
- func (s *Tokens) GetWithdrawalFunc(rw http.ResponseWriter, r *http.Request)
- func (s *Tokens) ListDeposits() http.Handler
- func (s *Tokens) ListDepositsFunc(rw http.ResponseWriter, r *http.Request)
- func (s *Tokens) ListWithdrawals() http.Handler
- func (s *Tokens) ListWithdrawalsFunc(rw http.ResponseWriter, r *http.Request)
- func (s *Tokens) MakeAccountTokensFunc(tType templates.TokenType) http.HandlerFunc
- func (s *Tokens) Setup() http.Handler
- func (s *Tokens) SetupFunc(rw http.ResponseWriter, r *http.Request)
- type Transactions
- func (s *Transactions) Create() http.Handler
- func (s *Transactions) CreateFunc(rw http.ResponseWriter, r *http.Request)
- func (s *Transactions) Details() http.Handler
- func (s *Transactions) DetailsFunc(rw http.ResponseWriter, r *http.Request)
- func (s *Transactions) ExecuteScript() http.Handler
- func (s *Transactions) ExecuteScriptFunc(rw http.ResponseWriter, r *http.Request)
- func (s *Transactions) List() http.Handler
- func (s *Transactions) ListFunc(rw http.ResponseWriter, r *http.Request)
- func (s *Transactions) Sign() http.Handler
- func (s *Transactions) SignFunc(rw http.ResponseWriter, r *http.Request)
Constants ¶
const SyncQueryParameter = "sync"
Variables ¶
var EmptyBodyError = &errors.RequestError{StatusCode: http.StatusBadRequest, Err: fmt.Errorf("empty body")}
var InvalidBodyError = &errors.RequestError{StatusCode: http.StatusBadRequest, Err: fmt.Errorf("invalid body")}
Functions ¶
func HandleHealthReady ¶ added in v0.9.0
func HandleHealthReady(w http.ResponseWriter, r *http.Request)
func IdempotencyHandler ¶ added in v0.9.0
func IdempotencyHandler(h http.Handler, opts IdempotencyHandlerOptions, store IdempotencyStore) http.Handler
IdempotencyHandler returns a http.HandlerFunc that checks for request idempotency when applicable
func UseIdempotency ¶ added in v0.9.0
func UseIdempotency(h http.Handler, opts IdempotencyHandlerOptions, store IdempotencyStore) http.Handler
Types ¶
type Accounts ¶
type Accounts struct {
// contains filtered or unexported fields
}
Accounts is a HTTP server for account management. It provides list, create and details APIs. It uses an account service to interface with data.
func NewAccounts ¶
NewAccounts initiates a new accounts server.
func (*Accounts) AddNonCustodialAccount ¶ added in v0.7.0
func (*Accounts) AddNonCustodialAccountFunc ¶ added in v0.7.0
func (s *Accounts) AddNonCustodialAccountFunc(rw http.ResponseWriter, r *http.Request)
func (*Accounts) CreateFunc ¶
func (s *Accounts) CreateFunc(rw http.ResponseWriter, r *http.Request)
Create creates a new account asynchronously. It returns a Job JSON representation.
func (*Accounts) DeleteNonCustodialAccount ¶ added in v0.7.0
func (*Accounts) DeleteNonCustodialAccountFunc ¶ added in v0.7.0
func (s *Accounts) DeleteNonCustodialAccountFunc(rw http.ResponseWriter, r *http.Request)
func (*Accounts) DetailsFunc ¶
func (s *Accounts) DetailsFunc(rw http.ResponseWriter, r *http.Request)
Details returns details regarding an account. It reads the address for the wanted account from URL. Account service is responsible for validating the address.
func (*Accounts) ListFunc ¶
func (s *Accounts) ListFunc(rw http.ResponseWriter, r *http.Request)
List returns all accounts.
func (*Accounts) SyncAccountKeyCount ¶ added in v0.10.0
func (*Accounts) SyncAccountKeyCountFunc ¶ added in v0.10.0
func (s *Accounts) SyncAccountKeyCountFunc(rw http.ResponseWriter, r *http.Request)
type IdempotencyHandlerOptions ¶ added in v0.9.0
type IdempotencyStore ¶ added in v0.9.0
type IdempotencyStoreGorm ¶ added in v0.9.0
type IdempotencyStoreGorm struct {
// contains filtered or unexported fields
}
Gorm (SQL) store for idempotency keys
func NewIdempotencyStoreGorm ¶ added in v0.9.0
func NewIdempotencyStoreGorm(db *gorm.DB) *IdempotencyStoreGorm
func (*IdempotencyStoreGorm) Get ¶ added in v0.9.0
func (g *IdempotencyStoreGorm) Get(key string) (bool, error)
func (*IdempotencyStoreGorm) Prune ¶ added in v0.9.0
func (g *IdempotencyStoreGorm) Prune() error
Prune deletes all expired IdempotencyStoreGormItems from the database
type IdempotencyStoreGormItem ¶ added in v0.9.0
type IdempotencyStoreGormItem struct { Key string `gorm:"column:key;primary_key"` ExpiryDate time.Time `gorm:"column:expiry_date"` }
TODO: automatically expire/prune keys w/ ExpiryDate in the past
func (IdempotencyStoreGormItem) TableName ¶ added in v0.9.0
func (IdempotencyStoreGormItem) TableName() string
type IdempotencyStoreLocal ¶ added in v0.9.0
type IdempotencyStoreLocal struct {
// contains filtered or unexported fields
}
Local / in-memory store for idempotency keys, mainly for testing purposes
func NewIdempotencyStoreLocal ¶ added in v0.9.0
func NewIdempotencyStoreLocal() *IdempotencyStoreLocal
type IdempotencyStoreRedis ¶ added in v0.9.0
type IdempotencyStoreRedis struct {
// contains filtered or unexported fields
}
Redis store for idempotency keys
func NewIdempotencyStoreRedis ¶ added in v0.9.0
func NewIdempotencyStoreRedis(c redis.Conn) *IdempotencyStoreRedis
type IdempotencyStoreType ¶ added in v0.9.0
type IdempotencyStoreType int
const ( IdempotencyStoreTypeLocal IdempotencyStoreType = iota IdempotencyStoreTypeRedis )
func (IdempotencyStoreType) String ¶ added in v0.9.0
func (ist IdempotencyStoreType) String() string
type Jobs ¶
type Jobs struct {
// contains filtered or unexported fields
}
Jobs is a HTTP server for jobs. It provides details API. It uses jobs service to interface with data.
func (*Jobs) DetailsFunc ¶
func (s *Jobs) DetailsFunc(rw http.ResponseWriter, r *http.Request)
Details returns details regarding a job. It reads the job id for the wanted job from URL. Job service is responsible for validating the job id.
type Ops ¶ added in v0.11.0
type Ops struct {
// contains filtered or unexported fields
}
Ops is a HTTP server for admin (system) operations.
func (*Ops) GetMissingFungibleVaults ¶ added in v0.11.0
GetMissingFungibleVaults returns number of accounts that are missing a configured fungible token vault.
func (*Ops) GetMissingFungibleVaultsFunc ¶ added in v0.11.0
func (s *Ops) GetMissingFungibleVaultsFunc(rw http.ResponseWriter, r *http.Request)
GetMissingFungibleVaultsFunc returns number of accounts with missing fungible token vaults.
func (*Ops) InitMissingFungibleVaults ¶ added in v0.11.0
InitMissingFungibleVaults starts the job to initialize missing fungible token vaults.
func (*Ops) InitMissingFungibleVaultsFunc ¶ added in v0.11.0
func (s *Ops) InitMissingFungibleVaultsFunc(rw http.ResponseWriter, r *http.Request)
InitMissingFungibleVaultsFunc starts job to init missing fungible token vaults.
type SyncKeyCountRequest ¶ added in v0.10.0
type SyncKeyCountRequest struct {
Address flow.Address `json:"address"`
}
SyncKeyCountRequest represents a JSON payload for a HTTP request
type System ¶ added in v0.9.0
type System struct {
// contains filtered or unexported fields
}
System is a HTTP server for system settings management.
func (*System) GetSettings ¶ added in v0.9.0
func (*System) SetSettings ¶ added in v0.9.0
type Templates ¶
type Templates struct {
// contains filtered or unexported fields
}
Templates is a HTTP server for template management.
func NewTemplates ¶
func (*Templates) AddTokenFunc ¶
func (s *Templates) AddTokenFunc(rw http.ResponseWriter, r *http.Request)
func (*Templates) GetTokenFunc ¶
func (s *Templates) GetTokenFunc(rw http.ResponseWriter, r *http.Request)
func (*Templates) ListTokens ¶
func (*Templates) MakeListTokensFunc ¶
func (s *Templates) MakeListTokensFunc(tType templates.TokenType) http.HandlerFunc
func (*Templates) RemoveToken ¶
func (*Templates) RemoveTokenFunc ¶
func (s *Templates) RemoveTokenFunc(rw http.ResponseWriter, r *http.Request)
type Tokens ¶
type Tokens struct {
// contains filtered or unexported fields
}
func (*Tokens) AccountTokens ¶
func (*Tokens) CreateWithdrawal ¶
func (*Tokens) CreateWithdrawalFunc ¶
func (s *Tokens) CreateWithdrawalFunc(rw http.ResponseWriter, r *http.Request)
func (*Tokens) DetailsFunc ¶
func (s *Tokens) DetailsFunc(rw http.ResponseWriter, r *http.Request)
func (*Tokens) GetDeposit ¶
func (*Tokens) GetDepositFunc ¶
func (s *Tokens) GetDepositFunc(rw http.ResponseWriter, r *http.Request)
func (*Tokens) GetWithdrawal ¶
func (*Tokens) GetWithdrawalFunc ¶
func (s *Tokens) GetWithdrawalFunc(rw http.ResponseWriter, r *http.Request)
func (*Tokens) ListDeposits ¶
func (*Tokens) ListDepositsFunc ¶
func (s *Tokens) ListDepositsFunc(rw http.ResponseWriter, r *http.Request)
func (*Tokens) ListWithdrawals ¶
func (*Tokens) ListWithdrawalsFunc ¶
func (s *Tokens) ListWithdrawalsFunc(rw http.ResponseWriter, r *http.Request)
func (*Tokens) MakeAccountTokensFunc ¶
func (s *Tokens) MakeAccountTokensFunc(tType templates.TokenType) http.HandlerFunc
type Transactions ¶
type Transactions struct {
// contains filtered or unexported fields
}
func NewTransactions ¶
func NewTransactions(service transactions.Service) *Transactions
NewTransactions initiates a new transactions server.
func (*Transactions) Create ¶
func (s *Transactions) Create() http.Handler
func (*Transactions) CreateFunc ¶
func (s *Transactions) CreateFunc(rw http.ResponseWriter, r *http.Request)
func (*Transactions) Details ¶
func (s *Transactions) Details() http.Handler
func (*Transactions) DetailsFunc ¶
func (s *Transactions) DetailsFunc(rw http.ResponseWriter, r *http.Request)
func (*Transactions) ExecuteScript ¶
func (s *Transactions) ExecuteScript() http.Handler
func (*Transactions) ExecuteScriptFunc ¶
func (s *Transactions) ExecuteScriptFunc(rw http.ResponseWriter, r *http.Request)
func (*Transactions) List ¶
func (s *Transactions) List() http.Handler
func (*Transactions) ListFunc ¶
func (s *Transactions) ListFunc(rw http.ResponseWriter, r *http.Request)
func (*Transactions) Sign ¶ added in v0.7.0
func (s *Transactions) Sign() http.Handler
func (*Transactions) SignFunc ¶ added in v0.7.0
func (s *Transactions) SignFunc(rw http.ResponseWriter, r *http.Request)