Documentation ¶
Index ¶
- Constants
- Variables
- func CE(id any, jsonRpc string, errMessage string) any
- func Capitalize(str string) string
- func Debug(msg any)
- func E(id any, jsonRpc string, errCode int) any
- func FilterRequestBody(jsonMap map[string]any) map[string]any
- func GetResult(b []byte, result any) error
- func GetSingleResponse(jsonData map[string]any, result any) error
- func GetStruct(d any, s any) error
- func JsonBatchRs(data []any) []byte
- func JsonRs(id any, method string, params any) []byte
- func ParseRequestBody(b []byte) (any, error)
- func ParseRequestMethod(method string) (sName string, mName string, err error)
- func ParseResponseBody(b []byte) (any, error)
- func ParseSingleRequestBody(jsonMap map[string]any) (id any, jsonrpc string, method string, params any, errCode int)
- func RegisterMethods(s reflect.Type) map[string]*Method
- func Rs(id any, method string, params any) any
- func S(id any, jsonRpc string, result any) any
- type Error
- type ErrorNotifyResponse
- type ErrorResponse
- type Hooks
- type Method
- type NotifyRequest
- type Request
- type Server
- func (svr *Server) After(id any, mName string, result any) error
- func (svr *Server) Before(id any, mName string, params any) error
- func (svr *Server) Handler(b []byte) []byte
- func (svr *Server) Register(s any) error
- func (svr *Server) RegisterWithName(s any, sname string) error
- func (svr *Server) SingleHandler(jsonMap map[string]any) any
- type Service
- type SingleRequest
- type SuccessNotifyResponse
- type SuccessResponse
Constants ¶
View Source
const ( WithoutError = 0 ParseError = -32700 InvalidRequest = -32600 MethodNotFound = -32601 InvalidParams = -32602 InternalError = -32603 CustomError = -32000 )
View Source
const (
JsonRpc = "2.0"
)
Variables ¶
View Source
var CodeMap = map[int]string{ ParseError: "Parse error", InvalidRequest: "Invalid request", MethodNotFound: "Method not found", InvalidParams: "Invalid params", InternalError: "Internal error", }
View Source
var RequiredFields = map[string]string{
"id": "id",
"jsonrpc": "jsonrpc",
"method": "method",
"params": "params",
}
Functions ¶
func Capitalize ¶
func JsonBatchRs ¶
func ParseRequestBody ¶
func ParseRequestMethod ¶
func ParseResponseBody ¶
func ParseSingleRequestBody ¶
Types ¶
type ErrorNotifyResponse ¶
type ErrorResponse ¶
type Method ¶
type Method struct { Name string ParamsType reflect.Type ResultType reflect.Type Method reflect.Method }
func RegisterMethod ¶
type NotifyRequest ¶
type Server ¶
func (*Server) RegisterWithName ¶ added in v0.0.5
type SingleRequest ¶
type SuccessNotifyResponse ¶
type SuccessResponse ¶
Click to show internal directories.
Click to hide internal directories.