Documentation ¶
Overview ¶
Package jsonrpc2http provides http implement of jsonrpc2(https://godoc.org/github.com/c0mm4nd/go-jsonrpc2), the fast jsonrpc 2.0 message encoding and decoding based on jsoniter
Visit repo https://godoc.org/github.com/c0mm4nd/go-jsonrpc2 and get example
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type HTTPHandler ¶
type HTTPHandler struct {
HandlerConfig
}
HTTPHandler is acting as a http.Handler and will redirect the jsonrpc message to one of the registered jsonrpc handlers on its handler table
func NewHTTPHandler ¶
func NewHTTPHandler(config HandlerConfig) *HTTPHandler
func (*HTTPHandler) RegisterJsonRpcHandleFunc ¶
func (h *HTTPHandler) RegisterJsonRpcHandleFunc(method string, fn func(*jsonrpc2.JsonRpcMessage) *jsonrpc2.JsonRpcMessage)
func (*HTTPHandler) RegisterJsonRpcHandler ¶
func (h *HTTPHandler) RegisterJsonRpcHandler(method string, handler JsonRpcHandler)
func (*HTTPHandler) ServeHTTP ¶
func (h *HTTPHandler) ServeHTTP(w http.ResponseWriter, req *http.Request)
type HandlerConfig ¶
type HandlerConfig struct { Logger Logger HandlerMap map[string]JsonRpcHandler }
type JsonRpcHandler ¶
type JsonRpcHandler interface {
Handle(*jsonrpc2.JsonRpcMessage) *jsonrpc2.JsonRpcMessage
}
type Server ¶
type Server struct { *http.Server *HTTPHandler }
func NewServer ¶
func NewServer(config ServerConfig) *Server
type ServerConfig ¶
type ServerConfig struct { Addr string Handler *HTTPHandler Logger Logger }
type SimpleLogger ¶
type SimpleLogger struct{}
func (*SimpleLogger) Debug ¶
func (logger *SimpleLogger) Debug(args ...interface{})
func (*SimpleLogger) Error ¶
func (logger *SimpleLogger) Error(args ...interface{})
Click to show internal directories.
Click to hide internal directories.