http

package
v0.4.6 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2024 License: Unlicense Imports: 23 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 JrpcToHttp added in v0.4.2

func JrpcToHttp(h jsonrpc.Handler) http.Handler

func ServerMaker

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

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 HttpCodec added in v0.4.0

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

func NewGetCodec added in v0.4.0

func NewGetCodec(w http.ResponseWriter, r *http.Request) *HttpCodec

func NewPostCodec added in v0.4.0

func NewPostCodec(w http.ResponseWriter, r *http.Request) (*HttpCodec, error)

func (*HttpCodec) Close added in v0.4.0

func (c *HttpCodec) Close() error

func (*HttpCodec) Closed added in v0.4.0

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

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

func (*HttpCodec) Flush added in v0.4.0

func (c *HttpCodec) Flush() error

func (*HttpCodec) PeerInfo added in v0.4.0

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

gets the peer info

func (*HttpCodec) ReadBatch added in v0.4.0

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

func (*HttpCodec) RemoteAddr added in v0.4.0

func (c *HttpCodec) RemoteAddr() string

RemoteAddr returns the peer address of the connection.

func (*HttpCodec) Write added in v0.4.0

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

closes the connection

type SseCodec added in v0.4.0

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

SseCodec is used for subscriptions over http. note that every message is buffered multiple times - it's a bit inefficient. if you need more efficient streaming of large blobs, consider using a different interface

func NewSseCodec added in v0.4.0

func NewSseCodec(w http.ResponseWriter, r *http.Request) (*SseCodec, error)

func (*SseCodec) Close added in v0.4.0

func (c *SseCodec) Close() error

func (*SseCodec) Closed added in v0.4.0

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

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

func (*SseCodec) Flush added in v0.4.0

func (c *SseCodec) Flush() error

func (*SseCodec) PeerInfo added in v0.4.0

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

gets the peer info

func (*SseCodec) ReadBatch added in v0.4.0

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

func (*SseCodec) RemoteAddr added in v0.4.0

func (c *SseCodec) RemoteAddr() string

RemoteAddr returns the peer address of the connection.

func (*SseCodec) Write added in v0.4.0

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

closes the connection

Jump to

Keyboard shortcuts

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