jsonrpc2

package
v1.2.6 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2022 License: MIT Imports: 10 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateBatchRequestBody

func GenerateBatchRequestBody(requests []*json.RawMessage) (*json.RawMessage, error)

GenerateBatchRequestBody ... JSONRPC2のバッチリクエストBodyを作成する

func GenerateRequestBody

func GenerateRequestBody(id string, method string, params interface{}) (*json.RawMessage, error)

GenerateRequestBody ... JSONRPC2のリクエストBodyを作成する

Types

type Action

type Action interface {
	DecodeParams(ctx context.Context, msg *json.RawMessage) (interface{}, error)
	Exec(ctx context.Context, method string, params interface{}) (interface{}, error)
}

Action ... JSORPC2アクションの定義

type Client

type Client struct {
	URL      string
	Headers  map[string]string
	Requests []*ClientRequest
}

Client ... JSONRPC2のリクエストを行う

func NewClient

func NewClient(url string, headers map[string]string) *Client

NewClient ... Clientを作成する

func (*Client) AddRequest

func (c *Client) AddRequest(ctx context.Context, id string, method string, params interface{}) error

AddRequest ... JSONRPC2のリクエストを登録する

func (*Client) DoBatch

func (c *Client) DoBatch(ctx context.Context) ([]*ClientResponse, error)

DoBatch ... JSONRPC2のバッチリクエストを行う

func (*Client) DoSingle

func (c *Client) DoSingle(ctx context.Context, method string, params interface{}) (*json.RawMessage, *ErrorResponse, error)

DoSingle ... JSONRPC2のシングルリクエストを行う

type ClientRequest

type ClientRequest struct {
	Version string           `json:"jsonrpc"`
	ID      string           `json:"id"`
	Method  string           `json:"method"`
	Params  *json.RawMessage `json:"params"`
}

ClientRequest ... JSONRPC2実行のリクエスト

type ClientResponse

type ClientResponse struct {
	Version string           `json:"jsonrpc"`
	ID      string           `json:"id"`
	Result  *json.RawMessage `json:"result,omitempty"`
	Error   *ErrorResponse   `json:"error,omitempty"`
}

ClientResponse ... JSONRPC2実行のレスポンス

type ErrorResponse

type ErrorResponse struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

ErrorResponse ... JSONRPC2のエラーレスポンス

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

Handler ... JSONRPC2に準拠したアクション

func NewHandler

func NewHandler() *Handler

NewHandler ... Handlerを作成する

func (*Handler) Handle

func (h *Handler) Handle(w http.ResponseWriter, r *http.Request)

Handle ... JSONRPC2のリクエストをハンドルする

func (*Handler) Register

func (h *Handler) Register(method string, action Action)

Register ... JSONRPC2のリクエストを登録する

Jump to

Keyboard shortcuts

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