request

package
v0.0.0-...-b4339e2 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2019 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewTLSConfig

func NewTLSConfig(c *Config) (*tls.Config, error)

Types

type Config

type Config struct {
	BearerToken string
	Timeout     time.Duration
	TLS         *TLSConfig
}

config holds the common attributes that can be passed to a Last.Backend client on initialization.

func (*Config) HasCA

func (c *Config) HasCA() bool

HasCA returns whether the configuration has a certificate authority or not.

func (*Config) HasCertAuth

func (c *Config) HasCertAuth() bool

HasCertAuth returns whether the configuration has certificate authentication or not.

func (*Config) HasTokenAuth

func (c *Config) HasTokenAuth() bool

HasTokenAuth returns whether the configuration has token authentication or not.

type HTTPClient

type HTTPClient interface {
	Do(req *http.Request) (*http.Response, error)
}

type IRESTClient

type IRESTClient interface {
	Do(verb string, path string) *Request
	Post(path string) *Request
	Put(path string) *Request
	Get(path string) *Request
	Delete(path string) *Request
}

type RESTClient

type RESTClient struct {
	Client      *http.Client
	BearerToken string
	// contains filtered or unexported fields
}

func DefaultRESTClient

func DefaultRESTClient(uri string) *RESTClient

func NewRESTClient

func NewRESTClient(uri string, cfg *Config) (*RESTClient, error)

func (*RESTClient) Delete

func (c *RESTClient) Delete(path string) *Request

func (*RESTClient) Do

func (c *RESTClient) Do(verb string, path string) *Request

func (*RESTClient) Get

func (c *RESTClient) Get(path string) *Request

func (*RESTClient) Post

func (c *RESTClient) Post(path string) *Request

func (*RESTClient) Put

func (c *RESTClient) Put(path string) *Request

type Request

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

func New

func New(client HTTPClient, method string, baseURL *url.URL) *Request

func (*Request) AddHeader

func (r *Request) AddHeader(key, val string) *Request

func (*Request) Body

func (r *Request) Body(data []byte) *Request

func (*Request) Do

func (r *Request) Do() Result

func (*Request) JSON

func (r *Request) JSON(success interface{}, failure interface{}) error

func (*Request) Param

func (r *Request) Param(name, value string) *Request

func (*Request) Stream

func (r *Request) Stream() (io.ReadCloser, error)

func (*Request) URL

func (r *Request) URL() *url.URL

type Result

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

func (Result) Error

func (r Result) Error() error

func (Result) Raw

func (r Result) Raw() ([]byte, error)

Raw returns the raw result.

func (Result) StatusCode

func (r Result) StatusCode() int

type TLSConfig

type TLSConfig struct {
	// Server should be accessed without verifying the TLS certificate. For testing only.
	Insecure bool

	// Override for the server name passed to the server for SNI and used to verify certificates..
	ServerName string

	// Server requires TLS client certificate authentication
	CertFile string
	// Server requires TLS client certificate authentication
	KeyFile string
	// Trusted root certificates for server
	CAFile string

	// Bytes of the PEM-encoded server trusted root certificates. Supersedes CAFile.
	CAData []byte
	// Bytes of the PEM-encoded client certificate. Supersedes CertFile.
	CertData []byte
	// Bytes of the PEM-encoded client key. Supersedes KeyFile.
	KeyData []byte
}

TLSConfig contains settings to enable transport layer security

Jump to

Keyboard shortcuts

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