client

package
v6.0.15 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2020 License: BSD-3-Clause Imports: 11 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultHTTPClient = &http.Client{
	Timeout: time.Second * 10,
	Transport: &http.Transport{
		TLSClientConfig: &tls.Config{
			ClientSessionCache: tls.NewLRUClientSessionCache(64),
		},
		TLSHandshakeTimeout: 5 * time.Second,
		MaxIdleConnsPerHost: 64,
	},
}

Functions

func DefaultErrorHandler

func DefaultErrorHandler(resp *Response) error

Types

type Client

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

func NewClient

func NewClient(address string, opts ...Option) *Client

func (*Client) Send

func (s *Client) Send(ctx context.Context, req *Request) (result *Response, err error)

type Codec

type Codec interface {
	Marshal(obj interface{}) (body []byte, err error)
	Unmarshal(data []byte, obj interface{}) error
	Name() string
}

Codec is interface for marshal/unmarshal

type Error

type Error struct {
	StatusCode int
	Message    string
	// contains filtered or unexported fields
}

func (*Error) Cause

func (e *Error) Cause() error

func (*Error) Error

func (e *Error) Error() string

func (*Error) Unwrap

func (e *Error) Unwrap() error

type JSONCodec

type JSONCodec struct{}

func (*JSONCodec) Marshal

func (c *JSONCodec) Marshal(obj interface{}) (body []byte, err error)

func (*JSONCodec) Name

func (c *JSONCodec) Name() string

func (*JSONCodec) Unmarshal

func (c *JSONCodec) Unmarshal(data []byte, obj interface{}) error

type Option

type Option func(o *options)

func DefaultCodec

func DefaultCodec(c Codec) Option

func DefaultHeader added in v6.0.4

func DefaultHeader(key string, val string) Option

func ErrorHandler

func ErrorHandler(h func(resp *Response) error) Option

func HTTPClient

func HTTPClient(c *http.Client) Option

func VirgilProduct

func VirgilProduct(product string, version string) Option

type Request

type Request struct {
	Method   string
	Endpoint string
	Header   http.Header
	Payload  interface{}
}

type Response

type Response struct {
	StatusCode int
	Header     http.Header
	Body       []byte
	// contains filtered or unexported fields
}

func (*Response) Unmarshal

func (r *Response) Unmarshal(v interface{}) error

Jump to

Keyboard shortcuts

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