http

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2020 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// http protocol name
	ProtocolHTTPName = "http"

	// https protocol name
	ProtocolHTTPSName = "https"
)

Variables

View Source
var (
	// DefaultTransport is default implementation of http.Transport.
	DefaultTransport = newDefaultTransport()

	// DefaultClient is default implementation of Client.
	DefaultClient = &Client{
		client:    &http.Client{Transport: DefaultTransport},
		transport: DefaultTransport,
	}
)

Functions

func NewHTTPMetaData

func NewHTTPMetaData() protocol.Metadata

NewHTTPMetaData generates an instance of protocol.Metadata.

func WithMapInterface

func WithMapInterface(opt map[string]interface{}) func(client protocol.Client) error

WithMapInterface allows to set some options by map interface. Supported: key: "tls.config", value: *tls.Config key: "http.transport" value: *http.Transport

func WithTLS

func WithTLS(config *tls.Config) func(protocol.Client) error

WithTLS allows to set tls config for http protocol of protocol.Client.

func WithTransport

func WithTransport(transport *http.Transport) func(protocol.Client)

WithTransport allows to set transport for http protocol of protocol.Client.

Types

type Client

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

Client is an implementation of protocol.Client for http protocol.

func (*Client) GetResource

func (cli *Client) GetResource(url string, md protocol.Metadata) protocol.Resource

type ClientBuilder

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

ClientBuilder is an implementation of protocol.ClientBuilder for http protocol.

func (*ClientBuilder) NewProtocolClient

func (cb *ClientBuilder) NewProtocolClient(opts ...func(client protocol.Client) error) (protocol.Client, error)

type Headers

type Headers struct {
	http.Header
}

Headers is an implementation of protocol.Metadata.

func (*Headers) All

func (hd *Headers) All() interface{}

func (*Headers) Del

func (hd *Headers) Del(key string)

func (*Headers) Get

func (hd *Headers) Get(key string) (interface{}, error)

func (*Headers) Set

func (hd *Headers) Set(key string, value interface{})

type Resource

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

Resource is an implementation of protocol.Resource for http protocol.

func (*Resource) Call

func (rs *Resource) Call(ctx context.Context, request interface{}) (response interface{}, err error)

func (*Resource) Close

func (rs *Resource) Close() error

func (*Resource) Expire

func (rs *Resource) Expire(ctx context.Context) (bool, interface{}, error)

func (*Resource) Length

func (rs *Resource) Length(ctx context.Context) (int64, error)

func (*Resource) Metadata

func (rs *Resource) Metadata(ctx context.Context) (protocol.Metadata, error)

func (*Resource) Read

func (rs *Resource) Read(ctx context.Context, off int64, size int64) (rc io.ReadCloser, err error)

Jump to

Keyboard shortcuts

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