Documentation
¶
Index ¶
Constants ¶
View Source
const ( ErrorCodeParseError = -32700 ErrorCodeInvalidRequest = -32600 ErrorCodeMethodNotFound = -32601 ErrorCodeInvalidParams = -32602 ErrorCodeInternalError = -32603 ErrorCodeServerError = -32000 )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Error ¶
type HandlerFunc ¶
func (HandlerFunc) HandleMethod ¶
type HttpHandler ¶
type HttpHandler struct {
Server JsonRpcServer
}
Implements the http.Handle interface
func NewHttpHandler ¶
func NewHttpHandler(server JsonRpcServer) *HttpHandler
func (*HttpHandler) ServeHTTP ¶
func (h *HttpHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
type Id ¶
type Id struct {
// contains filtered or unexported fields
}
A JSON-RPC Id
func (Id) MarshalJSON ¶
func (*Id) UnmarshalJSON ¶
type JsonRpcServer ¶
type Kind ¶
type Kind byte
Kind represents each possible JSON token kind with a single byte, which is conveniently the first byte of that kind's grammar with the restriction that numbers always be represented with '0':
- 'n': null
- 'f': false
- 't': true
- '"': string
- '0': number
- '{': object begin
- '}': object end
- '[': array begin
- ']': array end
An invalid kind is usually represented using 0, but may be non-zero due to invalid JSON data.
type MethodHandler ¶
type Params ¶
type Params struct {
// contains filtered or unexported fields
}
func (Params) ByPosition ¶
func (Params) MarshalJSON ¶
func (*Params) UnmarshalJSON ¶
type Request ¶
type Request struct {
JsonRpc string `json:"jsonrpc"`
Method string `json:"method"`
Params Params `json:"params,omitzero"`
Id Id `json:"id,omitzero"`
}
func NewNotification ¶
func (*Request) IsNotification ¶
type Response ¶
type Response struct {
JsonRpc string `json:"jsonrpc"`
Id Id `json:"id"`
Result json.RawMessage `json:"result,omitempty"`
Error *Error `json:"error,omitempty"`
}
func NewErrorResp ¶
func NewSuccessResp ¶
func NewSuccessResp(id Id, result json.RawMessage) *Response
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func (*Server) Register ¶
func (s *Server) Register(method string, handler MethodHandler)
func (*Server) RegisterFunc ¶
Source Files
¶
Click to show internal directories.
Click to hide internal directories.