Documentation ¶
Index ¶
- Constants
- Variables
- func CreateTransaction(r *request.Request, backend access.API, link models.LinkGenerator) (interface{}, error)
- func ExecuteScript(r *request.Request, backend access.API, _ models.LinkGenerator) (interface{}, error)
- func GetAccount(r *request.Request, backend access.API, link models.LinkGenerator) (interface{}, error)
- func GetBlockPayloadByID(r *request.Request, backend access.API, _ models.LinkGenerator) (interface{}, error)
- func GetBlocksByHeight(r *request.Request, backend access.API, link models.LinkGenerator) (interface{}, error)
- func GetBlocksByIDs(r *request.Request, backend access.API, link models.LinkGenerator) (interface{}, error)
- func GetCollectionByID(r *request.Request, backend access.API, link models.LinkGenerator) (interface{}, error)
- func GetEvents(r *request.Request, backend access.API, _ models.LinkGenerator) (interface{}, error)
- func GetExecutionResultByID(r *request.Request, backend access.API, link models.LinkGenerator) (interface{}, error)
- func GetExecutionResultsByBlockIDs(r *request.Request, backend access.API, link models.LinkGenerator) (interface{}, error)
- func GetNetworkParameters(r *request.Request, backend access.API, link models.LinkGenerator) (interface{}, error)
- func GetTransactionByID(r *request.Request, backend access.API, link models.LinkGenerator) (interface{}, error)
- func GetTransactionResultByID(r *request.Request, backend access.API, link models.LinkGenerator) (interface{}, error)
- func NewBlockProvider(backend access.API, options ...blockProviderOption) *blockProvider
- func NewServer(backend access.API, listenAddress string, logger zerolog.Logger, ...) (*http.Server, error)
- type ApiHandlerFunc
- type Error
- type Handler
- type StatusError
Constants ¶
const ( ExpandableFieldPayload = "payload" ExpandableExecutionResult = "execution_result" )
const MaxRequestSize = 2 << 20 // 2MB
Variables ¶
var Routes = []route{{ Method: http.MethodGet, Pattern: "/transactions/{id}", Name: "getTransactionByID", Handler: GetTransactionByID, }, { Method: http.MethodPost, Pattern: "/transactions", Name: "createTransaction", Handler: CreateTransaction, }, { Method: http.MethodGet, Pattern: "/transaction_results/{id}", Name: "getTransactionResultByID", Handler: GetTransactionResultByID, }, { Method: http.MethodGet, Pattern: "/blocks/{id}", Name: "getBlocksByIDs", Handler: GetBlocksByIDs, }, { Method: http.MethodGet, Pattern: "/blocks", Name: "getBlocksByHeight", Handler: GetBlocksByHeight, }, { Method: http.MethodGet, Pattern: "/blocks/{id}/payload", Name: "getBlockPayloadByID", Handler: GetBlockPayloadByID, }, { Method: http.MethodGet, Pattern: "/execution_results/{id}", Name: "getExecutionResultByID", Handler: GetExecutionResultByID, }, { Method: http.MethodGet, Pattern: "/execution_results", Name: "getExecutionResultByBlockID", Handler: GetExecutionResultsByBlockIDs, }, { Method: http.MethodGet, Pattern: "/collections/{id}", Name: "getCollectionByID", Handler: GetCollectionByID, }, { Method: http.MethodPost, Pattern: "/scripts", Name: "executeScript", Handler: ExecuteScript, }, { Method: http.MethodGet, Pattern: "/accounts/{address}", Name: "getAccount", Handler: GetAccount, }, { Method: http.MethodGet, Pattern: "/events", Name: "getEvents", Handler: GetEvents, }, { Method: http.MethodGet, Pattern: "/network/parameters", Name: "getNetworkParameters", Handler: GetNetworkParameters, }}
Functions ¶
func CreateTransaction ¶
func CreateTransaction(r *request.Request, backend access.API, link models.LinkGenerator) (interface{}, error)
CreateTransaction creates a new transaction from provided payload.
func ExecuteScript ¶
func ExecuteScript(r *request.Request, backend access.API, _ models.LinkGenerator) (interface{}, error)
ExecuteScript handler sends the script from the request to be executed.
func GetAccount ¶
func GetAccount(r *request.Request, backend access.API, link models.LinkGenerator) (interface{}, error)
GetAccount handler retrieves account by address and returns the response
func GetBlockPayloadByID ¶
func GetBlockPayloadByID(r *request.Request, backend access.API, _ models.LinkGenerator) (interface{}, error)
GetBlockPayloadByID gets block payload by ID
func GetBlocksByHeight ¶
func GetBlocksByIDs ¶
func GetBlocksByIDs(r *request.Request, backend access.API, link models.LinkGenerator) (interface{}, error)
GetBlocksByIDs gets blocks by provided ID or list of IDs.
func GetCollectionByID ¶
func GetCollectionByID(r *request.Request, backend access.API, link models.LinkGenerator) (interface{}, error)
GetCollectionByID retrieves a collection by ID and builds a response
func GetExecutionResultByID ¶
func GetExecutionResultByID(r *request.Request, backend access.API, link models.LinkGenerator) (interface{}, error)
GetExecutionResultByID gets execution result by the ID.
func GetExecutionResultsByBlockIDs ¶
func GetExecutionResultsByBlockIDs(r *request.Request, backend access.API, link models.LinkGenerator) (interface{}, error)
GetExecutionResultsByBlockIDs gets Execution Result payload by block IDs.
func GetNetworkParameters ¶
func GetNetworkParameters(r *request.Request, backend access.API, link models.LinkGenerator) (interface{}, error)
GetNetworkParameters returns network-wide parameters of the blockchain
func GetTransactionByID ¶
func GetTransactionByID(r *request.Request, backend access.API, link models.LinkGenerator) (interface{}, error)
GetTransactionByID gets a transaction by requested ID.
func GetTransactionResultByID ¶
func GetTransactionResultByID(r *request.Request, backend access.API, link models.LinkGenerator) (interface{}, error)
GetTransactionResultByID retrieves transaction result by the transaction ID.
func NewBlockProvider ¶
Types ¶
type ApiHandlerFunc ¶
type ApiHandlerFunc func( r *request.Request, backend access.API, generator models.LinkGenerator, ) (interface{}, error)
ApiHandlerFunc is a function that contains endpoint handling logic, it fetches necessary resources and returns an error or response model.
type Error ¶
type Error struct {
// contains filtered or unexported fields
}
Error is implementation of status error.
func NewBadRequestError ¶
NewBadRequestError creates a new bad request rest error.
func NewNotFoundError ¶
NewNotFoundError creates a new not found rest error.
func NewRestError ¶
NewRestError creates an error returned to user with provided status user displayed message and internal error
func (*Error) UserMessage ¶
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler is custom http handler implementing custom handler function. Handler function allows easier handling of errors and responses as it wraps functionality for handling error and responses outside of endpoint handling.
func NewHandler ¶
func NewHandler( logger zerolog.Logger, backend access.API, handlerFunc ApiHandlerFunc, generator models.LinkGenerator, chain flow.Chain, ) *Handler
type StatusError ¶
type StatusError interface { error // this is the actual error that occured Status() int // the HTTP status code to return UserMessage() string // the error message to return to the client }
StatusError provides custom error with http status.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
* Access API * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * * API version: 1.0.0 * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
|
* Access API * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * * API version: 1.0.0 * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) |