jsonrpc

package
v2.0.78 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 6, 2025 License: MIT Imports: 15 Imported by: 2

Documentation

Index

Constants

View Source
const (
	APP_NAME = "jsonrpc"
)

Variables

This section is empty.

Functions

func Priority

func Priority() int

func RootRouter

func RootRouter() *restful.Container

Types

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) Addr

func (h *JsonRpc) Addr() string

func (*JsonRpc) HTTPPrefix

func (h *JsonRpc) HTTPPrefix() string

func (*JsonRpc) Init

func (j *JsonRpc) Init() error

func (*JsonRpc) Name

func (j *JsonRpc) Name() string

func (*JsonRpc) Priority

func (j *JsonRpc) Priority() int

func (*JsonRpc) RPCURL

func (h *JsonRpc) RPCURL() string

func (*JsonRpc) Registry

func (j *JsonRpc) Registry(name string, svc any) error

1. 把业务 注册给RPC

type RPCReadWriteCloser

type RPCReadWriteCloser struct {
	io.Writer
	io.ReadCloser
}

func NewRPCReadWriteCloserFromHTTP

func NewRPCReadWriteCloserFromHTTP(w http.ResponseWriter, r *http.Request) *RPCReadWriteCloser

type Request

type Request[T any] struct {
	Method string `json:"method"`
	Params [1]T   `json:"params"`
	Id     uint64 `json:"id"`
}

func NewRequest

func NewRequest[T any](method string, Param T) *Request[T]

type Response

type Response[T any] struct {
	Id     uint64  `json:"id"`
	Result T       `json:"result"`
	Error  *string `json:"error"`
}

func NewResponse

func NewResponse[T any](id uint64, result T) *Response[T]

NewResponse 创建一个新的 Response 实例

type Service

type Service interface {
	Registry(name string, svc any) error
}

func GetService

func GetService() Service

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL