Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server represents a JSON-RPC server with middleware support. It wraps the underlying IRpcServer implementation and provides additional functionality.
func NewDefaultServer ¶
func NewDefaultServer(opts ...gsock.JsonRpcSimpleServiceOptionFunc) *Server
NewDefaultServer creates a new Server instance with default configuration. It accepts optional configuration functions that can modify the behavior of the JSON-RPC service. opts: Optional configuration functions for the JSON-RPC service Returns a pointer to the newly created Server instance
func (*Server) Middlewares ¶
func (s *Server) Middlewares() []gsock.RPCMiddleware
Middlewares returns the server's global middlewares. Returns: A slice of RPCMiddleware currently registered as global middlewares
func (*Server) RegisterHandle ¶
func (s *Server) RegisterHandle(api string, hand func(req *gsock.Request) (any, error), middlewares ...gsock.RPCMiddleware)
RegisterHandle registers a new handler function for a specific API endpoint. The handler will be wrapped with any provided middlewares, which will be executed in addition to the server's global middlewares. api: The API endpoint path (e.g., "/api/v1/method") hand: The handler function that processes the request and returns a response or error middlewares: Optional middlewares that apply only to this specific handler
func (*Server) Server ¶
func (s *Server) Server() gsock.IRpcServer
Server returns the underlying IRpcServer implementation. This provides access to the core server functionality if needed. Returns: The underlying IRpcServer instance
func (*Server) StartServer ¶
StartServer starts the JSON-RPC server listening on the specified Unix domain socket path. socketPath: The filesystem path where the Unix domain socket will be created Returns: An error if the server fails to start, nil otherwise