Documentation
¶
Index ¶
- Constants
- Variables
- func Priority() int
- func RegisterService(service any)
- func Registry(methodName string, handler HandlerFunc)
- func RootRouter() *restful.Container
- type HandlerFunc
- type JsonRpc
- func (h *JsonRpc) Addr() string
- func (h *JsonRpc) HTTPPrefix() string
- func (j *JsonRpc) HandleRequest(r *restful.Request, w *restful.Response)
- func (j *JsonRpc) Init() error
- func (j *JsonRpc) Name() string
- func (j *JsonRpc) PrintMethods()
- func (j *JsonRpc) Priority() int
- func (h *JsonRpc) RPCURL() string
- type MethodInfo
- type Request
- type Response
Constants ¶
View Source
const (
APP_NAME = "jsonrpc"
)
Variables ¶
View Source
var ( ErrProtocalError = exception.NewApiException(32600, "Invalid Request").WithHttpCode(400) ErrMethodNotFound = exception.NewApiException(32601, "Method not found").WithHttpCode(404) ErrInvalidParams = exception.NewApiException(32602, "Invalida Params").WithHttpCode(400) ErrInvalidMethodSignature = exception.NewApiException(32603, "invalid method signature").WithHttpCode(400) )
Functions ¶
func Registry ¶ added in v2.0.79
func Registry(methodName string, handler HandlerFunc)
1. 把业务 注册给RPC
func RootRouter ¶
func RootRouter() *restful.Container
Types ¶
type HandlerFunc ¶ added in v2.0.79
RPC 方法处理器类型
type JsonRpc ¶
type JsonRpc struct { ioc.ObjectImpl // 是否开启HTTP Server, 默认会根据是否有注册得有API对象来自动开启 Enable *bool `json:"enable" yaml:"enable" toml:"enable" env:"ENABLE"` // HTTP服务Host Host string `json:"host" yaml:"host" toml:"host" env:"HOST"` // HTTP服务端口 Port int `json:"port" yaml:"port" toml:"port" env:"PORT"` // API接口前缀 PathPrefix string `json:"path_prefix" yaml:"path_prefix" toml:"path_prefix" env:"PATH_PREFIX"` // 开启Trace Trace bool `toml:"trace" json:"trace" yaml:"trace" env:"TRACE"` // 访问日志 AccessLog bool `toml:"access_log" json:"access_log" yaml:"access_log" env:"ACCESS_LOG"` EnableSSL bool `json:"enable_ssl" yaml:"enable_ssl" toml:"enable_ssl" env:"ENABLE_SSL"` CertFile string `json:"cert_file" yaml:"cert_file" toml:"cert_file" env:"CERT_FILE"` KeyFile string `json:"key_file" yaml:"key_file" toml:"key_file" env:"KEY_FILE"` Container *restful.Container // contains filtered or unexported fields }
func (*JsonRpc) HTTPPrefix ¶
func (*JsonRpc) HandleRequest ¶ added in v2.0.79
func (j *JsonRpc) HandleRequest(r *restful.Request, w *restful.Response)
处理 JSON-RPC 请求
type MethodInfo ¶ added in v2.0.79
type MethodInfo struct { Name string // 方法名 Handler HandlerFunc // 处理器函数 FuncName string // 原始函数名 ParamType reflect.Type // 参数类型 }
方法信息结构
Click to show internal directories.
Click to hide internal directories.