sebak: boscoin.io/sebak/lib/node/runner/api Index | Files | Directories

package api

import "boscoin.io/sebak/lib/node/runner/api"

Index

Package Files

account.go api.go block.go blocks.go node_info.go operation.go pagequery.go stream.go transaction.go transaction_post.go tx_operations.go util.go

Constants

const (
    GetAccountTransactionsHandlerPattern   = "/accounts/{id}/transactions"
    GetAccountHandlerPattern               = "/accounts/{id}"
    GetAccountsHandlerPattern              = "/accounts"
    GetAccountOperationsHandlerPattern     = "/accounts/{id}/operations"
    GetAccountFrozenAccountHandlerPattern  = "/accounts/{id}/frozen-accounts"
    GetFrozenAccountHandlerPattern         = "/frozen-accounts"
    GetTransactionsHandlerPattern          = "/transactions"
    GetTransactionByHashHandlerPattern     = "/transactions/{id}"
    GetTransactionOperationsHandlerPattern = "/transactions/{id}/operations"
    GetTransactionOperationHandlerPattern  = "/transactions/{id}/operations/{opindex}"
    GetTransactionStatusHandlerPattern     = "/transactions/{id}/status"
    PostTransactionPattern                 = "/transactions"
    GetBlocksHandlerPattern                = "/blocks"
    GetBlockHandlerPattern                 = "/blocks/{hashOrHeight}"
    GetNodeInfoPattern                     = "/"
    PostSubscribePattern                   = "/subscribe"
)

API Endpoint patterns

const (
    DefaultLimit uint64 = 20
    MaxLimit     uint64 = 100
)
const APIVersionV1 = "v1"
const DefaultContentType = "application/json"

DefaultContentType is "application/json"

Variables

var RenderJSONFunc = func(args ...interface{}) ([]byte, error) {
    if len(args) <= 1 {
        return nil, fmt.Errorf("render: value is empty")
    }
    v := args[1]
    if v == nil {
        return nil, nil
    }
    bs, err := json.Marshal(v)
    if err != nil {
        return nil, err
    }
    return bs, nil
}

NewDefaultEventStream uses RenderJSONFunc by default

func NewTeeReadCloser Uses

func NewTeeReadCloser(origin io.ReadCloser, w io.Writer) io.ReadCloser

func TriggerEvent Uses

func TriggerEvent(st *storage.LevelDBBackend, transactions []*transaction.Transaction)

type EventStream Uses

type EventStream struct {
    // contains filtered or unexported fields
}

EventStream handles chunked responses of a observable trigger

renderFunc uses on observable.On() and Render function

func NewDefaultEventStream Uses

func NewDefaultEventStream(w http.ResponseWriter, r *http.Request) *EventStream

NewDefaultEventStream returns *EventStream with RenderJSONFunc and DefaultContentType

func NewEventStream Uses

func NewEventStream(w http.ResponseWriter, r *http.Request, renderFunc RenderFunc, ct string) *EventStream

NewEventStream makes *EventStream and checks http.Flusher by type assertion.

func (*EventStream) Render Uses

func (s *EventStream) Render(args ...interface{})

Render make a chunked response by using RenderFunc and flush it.

func (*EventStream) Run Uses

func (s *EventStream) Run(ob *observable.Observable, events ...string)

Run start observing events.

Simple use case:

event := fmt.Sprintf("address-%s", address)
es := NewDefaultEventStream(w, r)
es.Render(blk)
es.Run(observer.BlockAccountObserver, event)

func (*EventStream) Start Uses

func (s *EventStream) Start(ob *observable.Observable, events ...string) func()

Start prepares for observing events and returns run func.

In most case, Use Run instead of Start

func (*EventStream) Stop Uses

func (s *EventStream) Stop()

type NetworkHandlerAPI Uses

type NetworkHandlerAPI struct {
    GetLatestBlock func() block.Block
    // contains filtered or unexported fields
}

func NewNetworkHandlerAPI Uses

func NewNetworkHandlerAPI(localNode *node.LocalNode, network network.Network, storage *storage.LevelDBBackend, urlPrefix string, nodeInfo node.NodeInfo) *NetworkHandlerAPI

func (NetworkHandlerAPI) GetAccountHandler Uses

func (api NetworkHandlerAPI) GetAccountHandler(w http.ResponseWriter, r *http.Request)

func (NetworkHandlerAPI) GetAccountsHandler Uses

func (api NetworkHandlerAPI) GetAccountsHandler(w http.ResponseWriter, r *http.Request)

func (NetworkHandlerAPI) GetBlockHandler Uses

func (api NetworkHandlerAPI) GetBlockHandler(w http.ResponseWriter, r *http.Request)

func (NetworkHandlerAPI) GetBlocksHandler Uses

func (api NetworkHandlerAPI) GetBlocksHandler(w http.ResponseWriter, r *http.Request)

func (NetworkHandlerAPI) GetFrozenAccountsByAccountHandler Uses

func (api NetworkHandlerAPI) GetFrozenAccountsByAccountHandler(w http.ResponseWriter, r *http.Request)

func (NetworkHandlerAPI) GetFrozenAccountsHandler Uses

func (api NetworkHandlerAPI) GetFrozenAccountsHandler(w http.ResponseWriter, r *http.Request)

func (NetworkHandlerAPI) GetNodeInfoHandler Uses

func (api NetworkHandlerAPI) GetNodeInfoHandler(w http.ResponseWriter, r *http.Request)

func (NetworkHandlerAPI) GetOperationsByAccountHandler Uses

func (api NetworkHandlerAPI) GetOperationsByAccountHandler(w http.ResponseWriter, r *http.Request)

func (NetworkHandlerAPI) GetOperationsByTxHandler Uses

func (api NetworkHandlerAPI) GetOperationsByTxHandler(w http.ResponseWriter, r *http.Request)

func (NetworkHandlerAPI) GetOperationsByTxHashOpIndexHandler Uses

func (api NetworkHandlerAPI) GetOperationsByTxHashOpIndexHandler(w http.ResponseWriter, r *http.Request)

func (NetworkHandlerAPI) GetTransactionByHashHandler Uses

func (api NetworkHandlerAPI) GetTransactionByHashHandler(w http.ResponseWriter, r *http.Request)

func (NetworkHandlerAPI) GetTransactionStatusByHashHandler Uses

func (api NetworkHandlerAPI) GetTransactionStatusByHashHandler(w http.ResponseWriter, r *http.Request)

func (NetworkHandlerAPI) GetTransactionsByAccountHandler Uses

func (api NetworkHandlerAPI) GetTransactionsByAccountHandler(w http.ResponseWriter, r *http.Request)

func (NetworkHandlerAPI) GetTransactionsHandler Uses

func (api NetworkHandlerAPI) GetTransactionsHandler(w http.ResponseWriter, r *http.Request)

func (NetworkHandlerAPI) HandlerURLPattern Uses

func (api NetworkHandlerAPI) HandlerURLPattern(pattern string) string

func (NetworkHandlerAPI) PostSubscribeHandler Uses

func (api NetworkHandlerAPI) PostSubscribeHandler(w http.ResponseWriter, r *http.Request)

func (NetworkHandlerAPI) PostTransactionsHandler Uses

func (api NetworkHandlerAPI) PostTransactionsHandler(
    w http.ResponseWriter,
    r *http.Request,
    handler func([]byte, []common.CheckerFunc) (transaction.Transaction, error),
    funcs []common.CheckerFunc,
)

type PageQuery Uses

type PageQuery struct {
    // contains filtered or unexported fields
}

func NewPageQuery Uses

func NewPageQuery(r *http.Request, opts ...PageQueryOption) (*PageQuery, error)

func (*PageQuery) Cursor Uses

func (p *PageQuery) Cursor() []byte

func (*PageQuery) Limit Uses

func (p *PageQuery) Limit() uint64

func (*PageQuery) ListOptions Uses

func (p *PageQuery) ListOptions() storage.ListOptions
func (p *PageQuery) NextLink(cursor []byte) string
func (p *PageQuery) PrevLink(cursor []byte) string

func (*PageQuery) ResourceList Uses

func (p *PageQuery) ResourceList(rs []resource.Resource, firstCursor, lastCursor []byte) *resource.ResourceList

func (*PageQuery) Reverse Uses

func (p *PageQuery) Reverse() bool
func (p *PageQuery) SelfLink() string

func (*PageQuery) WalkOption Uses

func (p *PageQuery) WalkOption() *storage.WalkOption

type PageQueryOption Uses

type PageQueryOption func(*PageQuery)

func WithDefaultReverse Uses

func WithDefaultReverse(ok bool) PageQueryOption

func WithEncodePageCursor Uses

func WithEncodePageCursor(ok bool) PageQueryOption

type RenderFunc Uses

type RenderFunc func(args ...interface{}) ([]byte, error)

type TeeReadCloser Uses

type TeeReadCloser struct {
    io.ReadCloser
    // contains filtered or unexported fields
}

func (TeeReadCloser) Read Uses

func (tee TeeReadCloser) Read(p []byte) (n int, err error)

Directories

PathSynopsis
resource

Package api imports 22 packages (graph) and is imported by 6 packages. Updated 2019-03-27. Refresh now. Tools for package owners.