http

package
v0.3.10 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2023 License: Unlicense Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrClientQuit                = errors.New("client is closed")
	ErrNoResult                  = errors.New("no result in JSON-RPC response")
	ErrSubscriptionQueueOverflow = errors.New("subscription queue overflow")
)
View Source
var DefaultH2CClient = &http.Client{
	Transport: &http2.Transport{

		AllowHTTP: true,

		DialTLSContext: func(ctx context.Context, network, addr string, cfg *tls.Config) (net.Conn, error) {
			var d net.Dialer
			return d.DialContext(ctx, network, addr)
		},
	},
}
View Source
var ErrInvalidContentType = errors.New("invalid content type")

Functions

func HttpHandler

func HttpHandler(s *server.Server) http.Handler

func ServerMaker

func ServerMaker() (*server.Server, jrpctest.ClientMaker, func())

func ValidateRequest

func ValidateRequest(r *http.Request) (int, error)

validateRequest returns a non-zero response code and error message if the request is invalid.

Types

type Client

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

Client represents a connection to an RPC server.

func Dial

func Dial(ctx context.Context, client *http.Client, target string) (*Client, error)

func DialH2C added in v0.3.10

func DialH2C(target string) (*Client, error)

func DialHTTP

func DialHTTP(target string) (*Client, error)

func (*Client) Close

func (c *Client) Close() error

func (*Client) Closed

func (c *Client) Closed() <-chan struct{}

func (*Client) Do

func (c *Client) Do(ctx context.Context, result any, method string, params any) error

func (*Client) Mount

func (c *Client) Mount(h jsonrpc.Middleware)

func (*Client) Notify

func (c *Client) Notify(ctx context.Context, method string, params any) error

func (*Client) SetHeader

func (c *Client) SetHeader(key string, value string)

type Codec

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

Reusable codec. use Reset()

func NewCodec

func NewCodec(w http.ResponseWriter, r *http.Request) *Codec

func (*Codec) Close

func (c *Codec) Close() error

func (*Codec) Closed

func (c *Codec) Closed() <-chan struct{}

Closed returns a channel which is closed when the connection is closed.

func (*Codec) Flush

func (c *Codec) Flush() error

func (*Codec) PeerInfo

func (c *Codec) PeerInfo() jsonrpc.PeerInfo

gets the peer info

func (*Codec) ReadBatch

func (c *Codec) ReadBatch(ctx context.Context) ([]*jsonrpc.Message, bool, error)

func (*Codec) RemoteAddr

func (c *Codec) RemoteAddr() string

RemoteAddr returns the peer address of the connection.

func (*Codec) Reset

func (c *Codec) Reset(w http.ResponseWriter, r *http.Request)

func (*Codec) Write

func (c *Codec) Write(p []byte) (n int, err error)

closes the connection

type Server

type Server struct {
	Server *server.Server
}

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

Jump to

Keyboard shortcuts

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