Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MakeSessionToken ¶
MakeSessionToken creates a session token for RPC requests. If ttl is zero, the session will never expire.
func VerifySessionToken ¶
VerifySessionToken verifies that the given token was created using the given secretKey
Types ¶
type API ¶
type API interface {
APIs() APISet
}
API defines an interface for providing and accessing API functions. Packages that offer services accessed via RPC or any service-oriented interface must implement it.
type APIInfo ¶
type APIInfo struct {
// Func is the API function to be execute.
Func func(params interface{}) *Response
// Private indicates a requirement for a private, authenticated
// user session before this API function is executed.
Private bool
// Namespace is the JS namespace where the method should reside
Namespace string
// Description describes the API
Description string
}
APIInfo defines a standard API function type and other parameters.
type Err ¶
type Err struct {
Code int `json:"code"`
Message string `json:"message"`
Data interface{} `json:"data,omitempty"`
}
Err represents JSON RPC error object
type JSONRPC ¶
type JSONRPC struct {
// OnRequestFunc accepts a function. It is called
// each time a request is received. It is a good
// place to verify authentication. If error
// is returned, the handler is not called and
// the error is returned.
OnRequest OnRequestFunc
// contains filtered or unexported fields
}
JSONRPC defines a wrapper over mux json rpc that works with RPC functions of type `types.API` defined in packages that offer RPC APIs.`
func (*JSONRPC) MergeAPISet ¶
MergeAPISet merges an API set with s current api sets
func (*JSONRPC) Methods ¶
func (s *JSONRPC) Methods() (methodsInfo []MethodInfo)
Methods gets the names of all methods in the API set.
type MethodInfo ¶
type MethodInfo struct {
Name string `json:"name"`
Namespace string `json:"-"`
Description string `json:"description"`
Private bool `json:"private"`
}
MethodInfo describe an RPC method info
type OnRequestFunc ¶
OnRequestFunc is the type of function to use as a callback when new requests are received
type Request ¶
type Request struct {
JSONRPCVersion string `json:"jsonrpc"`
Method string `json:"method"`
Params interface{} `json:"params"`
ID interface{} `json:"id,omitempty"`
}
Request represent a JSON RPC request
func (Request) IsNotification ¶
IsNotification checks whether the request is a notification according to JSON RPC specification. When ID is nil, we assume it's a notification request.