jsonrpc2http

package
v0.0.0-...-66cb45a Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2021 License: MIT Imports: 6 Imported by: 4

README

jsonrpc2 - http

example is migrated to here

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

func NewClientRequest

func NewClientRequest(url string, message *jsonrpc2.JsonRpcMessage) (*http.Request, error)

Types

type Client

type Client struct {
	http.Client
}

func NewClient

func NewClient() *Client

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 Logger

type Logger interface {
	Debug(...interface{})
	Error(...interface{})
}

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{})

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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