Documentation
¶
Index ¶
- Constants
- Variables
- func NewServer(options ...ServerOption) (server *endpointServer, err error)
- type BackRpc
- func (r *BackRpc) AddRpcProcessor(method RpcMethod, processor RpcProcessor)
- func (r *BackRpc) Handle(ctx *fasthttp.RequestCtx)
- func (r *BackRpc) InitProcessors()
- func (r *BackRpc) RegisterProcessor(method RpcMethod, processor RpcProcessor)
- func (r *BackRpc) RegisterSecuredProcessor(method RpcMethod, processor RpcProcessor)
- func (r *BackRpc) RouteRpcRequest(ctx *fasthttp.RequestCtx) (err error)
- type BackRpcOption
- type DevForm
- type HttpResponse
- type JsonRpcError
- type JsonRpcRequest
- func (r *JsonRpcRequest) GetMethod() (method RpcMethod)
- func (r *JsonRpcRequest) GetParamBool(key string) (value bool, err error)
- func (r *JsonRpcRequest) GetParamFloat64(key string) (param float64, err error)
- func (r *JsonRpcRequest) GetParamInt(key string) (param int64, err error)
- func (r *JsonRpcRequest) GetParamRaw(key string) (param interface{}, found bool)
- func (r *JsonRpcRequest) GetParamString(key string) (param string, err error)
- func (r *JsonRpcRequest) ParseParams(params interface{}) (err error)
- type JsonRpcResponse
- type Number
- type Processor
- type RequestContext
- type RequestId
- type Router
- type RpcMethod
- type RpcProcessor
- type RpcRequest
- type RpcRequestContext
- func (r *RpcRequestContext) Authorized(v bool)
- func (r *RpcRequestContext) GetApiToken() (token string, err error)
- func (r *RpcRequestContext) GetBool(key string) (value bool, err error)
- func (r *RpcRequestContext) GetInt(key string) (value int64, err error)
- func (r *RpcRequestContext) GetString(key string) (value string, err error)
- func (r *RpcRequestContext) SetBool(key string, value bool)
- func (r *RpcRequestContext) SetInt(key string, value int64)
- func (r *RpcRequestContext) SetString(key, value string)
- type RpcResponse
- type ServerOption
- type TransferInfoResponse
Constants ¶
View Source
const ( MIME_TYPE_JSON = "application/json" ERROR_METHOD_NOT_ALLOWED = `{"error": {"code": -32601, "message": "method not found"}}` )
View Source
const ( JSON_RPC_VERSION = "2.0" ERROR_CODE_PARSE_ERROR = -32700 ERROR_MESSAGE_PARSE_ERROR = "Parse error" ERROR_CODE_INVALID_REQUEST = -32600 ERROR_MESSAGE_INVALID_REQUEST = "invalid request" ERROR_CODE_METHOD_NOT_FOUND = -32601 ERROR_MESSAGE_METHOD_NOT_FOUND = "method not found" ERROR_CODE_SERVER_ERROR = -32000 ERROR_MESSAGE_SERVER_ERROR = "server error" ERROR_CODE_UNAUTHORIZED = -32001 ERROR_MESSAGE_UNAUTHORIZED = "unauthorized access" )
View Source
const (
MIME_TYPE_TEXT_HTML = "text/html"
)
Variables ¶
Functions ¶
func NewServer ¶
func NewServer(options ...ServerOption) (server *endpointServer, err error)
Types ¶
type BackRpc ¶
type BackRpc struct {
// contains filtered or unexported fields
}
func NewBackRpc ¶
func NewBackRpc(addressPool *address.Manager, chainClient types.ChainClient, subscriptions *subscriptions.Manager, watchdog *watchdog.Service, txCache types.TxCache, options ...BackRpcOption) *BackRpc
func (*BackRpc) AddRpcProcessor ¶
func (r *BackRpc) AddRpcProcessor(method RpcMethod, processor RpcProcessor)
func (*BackRpc) Handle ¶
func (r *BackRpc) Handle(ctx *fasthttp.RequestCtx)
func (*BackRpc) InitProcessors ¶
func (r *BackRpc) InitProcessors()
func (*BackRpc) RegisterProcessor ¶
func (r *BackRpc) RegisterProcessor(method RpcMethod, processor RpcProcessor)
func (*BackRpc) RegisterSecuredProcessor ¶
func (r *BackRpc) RegisterSecuredProcessor(method RpcMethod, processor RpcProcessor)
func (*BackRpc) RouteRpcRequest ¶
func (r *BackRpc) RouteRpcRequest(ctx *fasthttp.RequestCtx) (err error)
type BackRpcOption ¶
type BackRpcOption func(r *BackRpc)
func WithDebugMode ¶
func WithDebugMode(debugMode bool) BackRpcOption
func WithFallbackResponse ¶
func WithFallbackResponse(response HttpResponse) BackRpcOption
func WithRpcProcessor ¶
func WithRpcProcessor(method RpcMethod, processor RpcProcessor) BackRpcOption
func WithSecurityManager ¶
func WithSecurityManager(securityManager *security.Manager) BackRpcOption
type DevForm ¶
type DevForm struct {
FormPath string
}
func (DevForm) ContentType ¶
func (DevForm) StatusCode ¶
type HttpResponse ¶
type JsonRpcError ¶
type JsonRpcRequest ¶
type JsonRpcRequest struct {
Id RequestId `json:"id"`
JsonRpc string `json:"jsonrpc"`
Method RpcMethod `json:"method"`
Params json.RawMessage `json:"params,omitempty"`
// contains filtered or unexported fields
}
func (*JsonRpcRequest) GetMethod ¶
func (r *JsonRpcRequest) GetMethod() (method RpcMethod)
func (*JsonRpcRequest) GetParamBool ¶
func (r *JsonRpcRequest) GetParamBool(key string) (value bool, err error)
func (*JsonRpcRequest) GetParamFloat64 ¶
func (r *JsonRpcRequest) GetParamFloat64(key string) (param float64, err error)
func (*JsonRpcRequest) GetParamInt ¶
func (r *JsonRpcRequest) GetParamInt(key string) (param int64, err error)
func (*JsonRpcRequest) GetParamRaw ¶
func (r *JsonRpcRequest) GetParamRaw(key string) (param interface{}, found bool)
func (*JsonRpcRequest) GetParamString ¶
func (r *JsonRpcRequest) GetParamString(key string) (param string, err error)
func (*JsonRpcRequest) ParseParams ¶
func (r *JsonRpcRequest) ParseParams(params interface{}) (err error)
type JsonRpcResponse ¶
type JsonRpcResponse struct {
Id RequestId `json:"id"`
JsonRpc string `json:"jsonrpc"`
Error *JsonRpcError `json:"error,omitempty"`
Result json.RawMessage `json:"result,omitempty"`
}
func NewResponse ¶
func NewResponse() *JsonRpcResponse
func (*JsonRpcResponse) SetError ¶
func (r *JsonRpcResponse) SetError(code int, message string)
func (*JsonRpcResponse) SetErrorWithData ¶
func (r *JsonRpcResponse) SetErrorWithData(code int, message, data string)
func (*JsonRpcResponse) SetResult ¶
func (r *JsonRpcResponse) SetResult(result interface{})
func (*JsonRpcResponse) SetResultBytes ¶
func (r *JsonRpcResponse) SetResultBytes(result []byte)
type Processor ¶
type Processor interface {
Process(ctx RequestContext, request RpcRequest, result RpcResponse) (err error)
}
type RequestContext ¶
type RequestContext interface {
GetString(key string) (value string, err error)
GetInt(key string) (value int64, err error)
GetBool(key string) (value bool, err error)
GetApiToken() (token string, err error)
SetBool(key string, value bool)
SetString(key string, value string)
SetInt(key string, value int64)
Authorized(bool)
}
type RequestId ¶
type RequestId string
func (RequestId) MarshalJSON ¶
func (*RequestId) UnmarshalJSON ¶
type RpcProcessor ¶
type RpcProcessor func(ctx RequestContext, request RpcRequest, response RpcResponse)
type RpcRequest ¶
type RpcRequestContext ¶
type RpcRequestContext struct {
// contains filtered or unexported fields
}
func NewRpcRequestContext ¶
func NewRpcRequestContext() *RpcRequestContext
func (*RpcRequestContext) Authorized ¶
func (r *RpcRequestContext) Authorized(v bool)
func (*RpcRequestContext) GetApiToken ¶
func (r *RpcRequestContext) GetApiToken() (token string, err error)
func (*RpcRequestContext) GetBool ¶
func (r *RpcRequestContext) GetBool(key string) (value bool, err error)
func (*RpcRequestContext) GetInt ¶
func (r *RpcRequestContext) GetInt(key string) (value int64, err error)
func (*RpcRequestContext) GetString ¶
func (r *RpcRequestContext) GetString(key string) (value string, err error)
func (*RpcRequestContext) SetBool ¶
func (r *RpcRequestContext) SetBool(key string, value bool)
func (*RpcRequestContext) SetInt ¶
func (r *RpcRequestContext) SetInt(key string, value int64)
func (*RpcRequestContext) SetString ¶
func (r *RpcRequestContext) SetString(key, value string)
type RpcResponse ¶
type ServerOption ¶
type ServerOption func(s *endpointServer) error
func WithHandler ¶
func WithHandler(handler fasthttp.RequestHandler) ServerOption
func WithHttpListener ¶
func WithHttpListener(listenAddress string) ServerOption
func WithSocketListener ¶
func WithSocketListener(socketFile string) ServerOption
func WithSshListener ¶
func WithSshListener(listenPort int, knownKeys []string) ServerOption
type TransferInfoResponse ¶
type TransferInfoResponse struct {
TxID string `json:"tx_id"`
Timestamp int64 `json:"timestamp"`
BlockNum int `json:"blockNum"`
Success bool `json:"success"`
Transfer bool `json:"transfer"`
NativeCoin bool `json:"nativeCoin,omitempty"`
Symbol string `json:"symbol,omitempty"`
Decimals int `json:"decimals"`
SmartContract bool `json:"smartContract,omitempty"`
From string `json:"from"`
To string `json:"to"`
Amount amount `json:"amount"`
Token string `json:"token,omitempty"`
TokenSymbol string `json:"tokenSymbol,omitempty"`
Fee amount `json:"fee"`
InPool bool `json:"inPool"`
Confirmed bool `json:"confirmed"`
Confirmations int `json:"confirmations,omitempty"`
ChainSpecificData []byte `json:"chainSpecificData,omitempty"`
}
Source Files
¶
Click to show internal directories.
Click to hide internal directories.