request

package
v0.9.2-alpha Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2017 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsNotFound

func IsNotFound(err error) bool

Types

type HTTPClient

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

HTTPClient is an interface for testing a request object.

type HTTPError

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

func NewHTTPError

func NewHTTPError(statusCode int, message string, format ...interface{}) *HTTPError

func (*HTTPError) Error

func (h *HTTPError) Error() string

type Interface

type Interface interface {
	Get() *Request
	Post() *Request
	Put() *Request
	Patch() *Request
	Delete() *Request
	Verb(verb string) *Request
	Reset() *Request
}

type Request

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

func NewRequest

func NewRequest(client HTTPClient, baseURL *url.URL) *Request

func (*Request) AddQuery

func (r *Request) AddQuery(key, value string) *Request

func (*Request) Body

func (r *Request) Body(bodyData interface{}) *Request

func (*Request) Context

func (r *Request) Context(ctx context.Context) *Request

Context adds a context to the request. Contexts are only used for timeouts, deadlines, and cancellations.

func (*Request) Delete

func (r *Request) Delete() *Request

func (*Request) Do

func (r *Request) Do() *Result

func (*Request) Error

func (r *Request) Error() error

func (*Request) Get

func (r *Request) Get() *Request

func (*Request) Name

func (r *Request) Name(resourceName string) *Request

func (*Request) Patch

func (r *Request) Patch() *Request

func (*Request) Post

func (r *Request) Post() *Request

func (*Request) Prefix

func (r *Request) Prefix(segments ...string) *Request

Prefix adds segments to the relative beginning to the request path. These items will be placed before the Resource, or Name sections.

func (*Request) Put

func (r *Request) Put() *Request

func (*Request) RequestPath

func (r *Request) RequestPath(basePath string) *Request

RequestPath override the basePath of the request

func (*Request) Reset

func (r *Request) Reset() *Request

Reset will clean all paths

func (*Request) Resource

func (r *Request) Resource(name string) *Request

func (*Request) SetHeader

func (r *Request) SetHeader(key, value string) *Request

func (*Request) Timeout

func (r *Request) Timeout(d time.Duration) *Request

Timeout makes the request use the given duration as a timeout. Sets the "timeout" parameter.

func (*Request) URL

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

func (*Request) Verb

func (r *Request) Verb(verb string) *Request

type Result

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

Result contains the result of calling Request.Do().

func (Result) ContentType

func (r Result) ContentType() string

func (Result) Error

func (r Result) Error() error

func (Result) Into

func (r Result) Into(obj interface{}) error

func (Result) IsSuccess

func (r Result) IsSuccess() bool

func (Result) Raw

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

func (Result) StatusCode

func (r Result) StatusCode() int

Jump to

Keyboard shortcuts

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