request

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2021 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Client   *http.Client
	Headers  http.Header
	BasePath string
}

Client provides a wrapper around http client

func NewClient

func NewClient(cluster *config.Cluster) *Client

create a request client with global configurations

func (*Client) AddHeader

func (client *Client) AddHeader(key, value string) http.Header

func (*Client) NewRequest

func (client *Client) NewRequest(options Options) (*Request, error)

creates a new request object, this needs to be invoke for every call client will hold all the global info about the request

type GlobalOptions

type GlobalOptions struct {
	Timeout  time.Duration
	BasePath string
	Headers  http.Header
}

global client options

type Options

type Options struct {
	Url     string
	Method  string
	Headers http.Header
	Body    interface{}
	Query   map[string]string
}

options object

type Request

type Request struct {
	Req    *http.Request
	Client *http.Client
}

func (*Request) Send

func (req *Request) Send() (*Response, error)

triggers the api call and returns error or response object

type Response

type Response struct {
	Res *http.Response
}

func (*Response) GetBody

func (wr *Response) GetBody() ([]byte, error)

response wrapper for returning bytes of data returned by response

func (*Response) GetHeaders

func (wr *Response) GetHeaders() http.Header

response wrapper for returning headers filed from response

func (*Response) GetStatusCode

func (wr *Response) GetStatusCode() int

response wrapper for returning the status code

Jump to

Keyboard shortcuts

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