Documentation
¶
Index ¶
Constants ¶
const ( // Pre-defined errors for JSON-RPC 2.0 https://www.jsonrpc.org/specification#error_object CodeParseError = -32700 CodeInvalidRequest = -32600 CodeMethodNotFound = -32601 CodeInvalidParams = -32602 CodeInternalError = -32603 // -32000 to -32099 Are application level errors (i.e. define your rpc errors in this range) CodeNotAllowed = -32001 CodeNotFound = -32000 )
const ( // All incoming requests must show this MIME type in the header ContentType = "application/json" PathJSON = "/jsonrpc" PathGOB = "/rpc/gob" Path = PathJSON )
The http path used for our rpc handlers
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Error ¶ added in v0.10.8
func InternalError ¶ added in v0.10.8
func InvalidParamsError ¶ added in v0.10.8
func InvalidRequestError ¶ added in v0.10.8
func MethodNotFoundError ¶ added in v0.10.8
func NotAllowedError ¶ added in v0.10.8
func ParseError ¶ added in v0.10.8
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server holds an RPC server that is served over HTTP
func (*Server) Prepare ¶
Prepare injects all the data necessary for serving over the specified URL. It prepares a net.Listener over the specified URL, and registers all methods inside the given receiver. After this method is called, the Start function is ready to be called.
func (*Server) Register ¶ added in v0.10.8
Register creates a service on the Server with the given name. The criteria of a service method is the same as defined in the net/rpc package: - the method's type is exported. - the method is exported. - the method has two arguments, both exported (or builtin) types. - the method's second argument is a pointer. - the method has return type error.
func (*Server) RegisterRestfulMap ¶ added in v0.12.0
func (srv *Server) RegisterRestfulMap(routerMap map[string]http.HandlerFunc)
RegisterRestfulMap registers all restful API functions in a map on the Server