Categorygithub.com/kechako/go-jsonrpc
modulepackage
0.1.0
Repository: https://github.com/kechako/go-jsonrpc.git
Documentation: pkg.go.dev

# README

= go-jsonrpc

go-jsonrpc is a JSON-RPC 2.0 client that communicates over HTTP in Go.

== Install

[source, console]

$ go get github.com/kechako/go-jsonrpc

=== Usage

[source, golang]

package main

import ( "context" "fmt" "log" "net/http"

"github.com/kechako/go-jsonrpc"

)

type Query struct { Email string }

type Result struct { ID uint64 Name string Address string }

func main() { c := &jsonrpc.Client{}

q := &Query{
	Email: "[email protected]",
}

header := make(http.Header)
header.Add("X-Custom-Header", "XXXX")

var res Result
err := c.Call(context.Background(), "https://example.com/jsonrpc", "query", q, &res, jsonrpc.WithHeader(header))
if err != nil {
	log.Fatal(err)
}

fmt.Println(res.ID, res.Name, res.Address)

}

# Functions

No description provided by the author

# Constants

nternal JSON-RPC error.
Invalid method parameter(s).
The JSON sent is not a valid Request object.
The method does not exist or is not available.
Invalid JSON was received by the server.
Version is a JSON-RPC version.

# Structs

Client represents a JSPN-RPC 2.0 Client.
ResponseError represents an error responded by the server.

# Interfaces

Option represents an option used to method calling.

# Type aliases

ErrorCode is a number that indicates the error type that occurred.