Documentation ¶
Index ¶
- Constants
- func NewBlockProvider(backend access.API, options ...blockProviderOption) *blockProvider
- func NewServer(backend access.API, listenAddress string, logger zerolog.Logger) *http.Server
- func SelectFilter(object interface{}, selectKeys []string) (interface{}, error)
- type ApiHandlerFunc
- type Handler
- type LinkFunc
- type LinkGenerator
- type LinkGeneratorImpl
- func (generator *LinkGeneratorImpl) AccountLink(address string) (string, error)
- func (generator *LinkGeneratorImpl) BlockLink(id flow.Identifier) (string, error)
- func (generator *LinkGeneratorImpl) CollectionLink(id flow.Identifier) (string, error)
- func (generator *LinkGeneratorImpl) ExecutionResultLink(id flow.Identifier) (string, error)
- func (generator *LinkGeneratorImpl) PayloadLink(id flow.Identifier) (string, error)
- func (generator *LinkGeneratorImpl) TransactionLink(id flow.Identifier) (string, error)
- func (generator *LinkGeneratorImpl) TransactionResultLink(id flow.Identifier) (string, error)
- type RestError
- type StatusError
Examples ¶
Constants ¶
const ( ExpandableFieldPayload = "payload" ExpandableExecutionResult = "execution_result" )
const MaxAllowedHeights = 50
const MaxAllowedIDs = 50
Variables ¶
This section is empty.
Functions ¶
func NewBlockProvider ¶ added in v0.23.5
func SelectFilter ¶ added in v0.23.5
SelectFilter selects the specified keys from the given object. The keys are in the json dot notation and must refer to leaf elements e.g. payload.collection_guarantees.signer_ids
Example ¶
blocks := make([]generated.Block, 2) for i := range blocks { block, err := generateBlock() if err != nil { fmt.Println(err) return } blocks[i] = block } selectKeys := []string{ "header.id", "payload.collection_guarantees.signature", "payload.block_seals.aggregated_approval_signatures.signer_ids", "payload.collection_guarantees.signer_ids", "execution_result.events.event_index", "something.nonexisting", } filteredBlock, err := SelectFilter(blocks, selectKeys) if err != nil { fmt.Println(err) return } marshalled, err := json.MarshalIndent(filteredBlock, "", "\t") if err != nil { panic(err.Error()) } fmt.Println(string(marshalled))
Output: [ { "execution_result": { "events": [ { "event_index": "2" }, { "event_index": "3" } ] }, "header": { "id": "abcd" }, "payload": { "block_seals": [ { "aggregated_approval_signatures": [ { "signer_ids": [ "abcdef0123456789", "abcdef0123456789" ] } ] } ], "collection_guarantees": [ { "signature": "abcdef0123456789", "signer_ids": [ "abcdef0123456789", "abcdef0123456789" ] } ] } }, { "execution_result": { "events": [ { "event_index": "2" }, { "event_index": "3" } ] }, "header": { "id": "abcd" }, "payload": { "block_seals": [ { "aggregated_approval_signatures": [ { "signer_ids": [ "abcdef0123456789", "abcdef0123456789" ] } ] } ], "collection_guarantees": [ { "signature": "abcdef0123456789", "signer_ids": [ "abcdef0123456789", "abcdef0123456789" ] } ] } } ]
Types ¶
type ApiHandlerFunc ¶ added in v0.23.5
type ApiHandlerFunc func( r *request, backend access.API, generator LinkGenerator, ) (interface{}, error)
ApiHandlerFunc is a function that contains endpoint handling logic, it fetches necessary resources and returns an error or response model.
type Handler ¶ added in v0.23.5
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 ¶ added in v0.23.5
func NewHandler(logger zerolog.Logger, backend access.API, handlerFunc ApiHandlerFunc, generator LinkGenerator) *Handler
type LinkGenerator ¶ added in v0.23.5
type LinkGenerator interface { BlockLink(id flow.Identifier) (string, error) TransactionLink(id flow.Identifier) (string, error) TransactionResultLink(id flow.Identifier) (string, error) PayloadLink(id flow.Identifier) (string, error) ExecutionResultLink(id flow.Identifier) (string, error) AccountLink(address string) (string, error) CollectionLink(id flow.Identifier) (string, error) }
LinkGenerator generates the expandable value for the known endpoints e.g. "/v1/blocks/c5e935bc75163db82e4a6cf9dc3b54656709d3e21c87385138300abd479c33b7"
type LinkGeneratorImpl ¶ added in v0.23.5
type LinkGeneratorImpl struct {
// contains filtered or unexported fields
}
func NewLinkGeneratorImpl ¶ added in v0.23.5
func NewLinkGeneratorImpl(router *mux.Router) *LinkGeneratorImpl
func (*LinkGeneratorImpl) AccountLink ¶ added in v0.23.5
func (generator *LinkGeneratorImpl) AccountLink(address string) (string, error)
func (*LinkGeneratorImpl) BlockLink ¶ added in v0.23.5
func (generator *LinkGeneratorImpl) BlockLink(id flow.Identifier) (string, error)
func (*LinkGeneratorImpl) CollectionLink ¶ added in v0.23.5
func (generator *LinkGeneratorImpl) CollectionLink(id flow.Identifier) (string, error)
func (*LinkGeneratorImpl) ExecutionResultLink ¶ added in v0.23.5
func (generator *LinkGeneratorImpl) ExecutionResultLink(id flow.Identifier) (string, error)
func (*LinkGeneratorImpl) PayloadLink ¶ added in v0.23.5
func (generator *LinkGeneratorImpl) PayloadLink(id flow.Identifier) (string, error)
func (*LinkGeneratorImpl) TransactionLink ¶ added in v0.23.5
func (generator *LinkGeneratorImpl) TransactionLink(id flow.Identifier) (string, error)
func (*LinkGeneratorImpl) TransactionResultLink ¶ added in v0.23.5
func (generator *LinkGeneratorImpl) TransactionResultLink(id flow.Identifier) (string, error)
type RestError ¶ added in v0.23.5
type RestError struct {
// contains filtered or unexported fields
}
RestError is implementation of status error.
func NewBadRequestError ¶ added in v0.23.5
NewBadRequestError creates a new bad request rest error.
func NewNotFoundError ¶ added in v0.23.5
NewNotFoundError creates a new not found rest error.
func NewRestError ¶ added in v0.23.5
NewRestError creates an error returned to user with provided status user displayed message and internal error
func (*RestError) UserMessage ¶ added in v0.23.5
type StatusError ¶ added in v0.23.5
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.
func NotImplemented ¶ added in v0.23.5
func NotImplemented( _ *request, _ access.API, _ LinkGenerator, ) (interface{}, StatusError)
NotImplemented handler returns an error explaining the endpoint is not yet implemented
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) * 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) * 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) * 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) * 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) * 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) * 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) * 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) * 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) * 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) * 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) * 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) * 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) * 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) * 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) * 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) * 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) * 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) * 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) * 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) * 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) * 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) * 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) * 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) * 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) * 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) * 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) * 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) * 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) * 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) * 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) |