client

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2019 License: MIT Imports: 5 Imported by: 24

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client ...

func Get

func Get(path string) *Client

Get builds a GET request.

func Post

func Post(path string) *Client

Post builds a POST request.

func (*Client) Body

func (http *Client) Body(raw string) *Client

Body sets the request body.

func (*Client) BodyBytes

func (http *Client) BodyBytes(raw []byte) *Client

BodyBytes sets the request body as a byte slice.

func (*Client) BodyJSON

func (http *Client) BodyJSON(obj interface{}) *Client

BodyJSON sets the request body by converting the object to JSON.

func (*Client) End

func (http *Client) End() (Response, error)

End executes the request and returns the response.

func (*Client) EndStruct

func (http *Client) EndStruct(obj interface{}) (Response, error)

EndStruct executes the request, unmarshals the response body into a struct and returns the response.

func (*Client) Header

func (http *Client) Header(key string, value string) *Client

Header sets one HTTP header for the request.

func (*Client) Headers

func (http *Client) Headers(headers Headers) *Client

Headers sets the HTTP headers for the request.

func (*Client) Response

func (http *Client) Response() Response

Response returns the response object.

type Headers

type Headers map[string]string

Headers is a synonym for map[string]string.

type Response

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

Response represents the HTTP response used in the given client.

func (Response) Bytes

func (response Response) Bytes() []byte

Bytes returns the response body as a byte slice and unzips gzipped content when necessary.

func (Response) RawBytes

func (response Response) RawBytes() []byte

RawBytes returns the raw response body as a byte slice.

func (Response) RawString

func (response Response) RawString() string

RawString returns the raw response body as a string.

func (Response) StatusCode

func (response Response) StatusCode() int

StatusCode returns the status code of the response.

func (Response) String

func (response Response) String() string

String returns the response body as a string.

func (Response) Unmarshal

func (response Response) Unmarshal(obj interface{}) error

Unmarshal tries to JSON decode the response and save it in the object.

Jump to

Keyboard shortcuts

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