requist

package module
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2020 License: MIT Imports: 11 Imported by: 0

README

Library to manage HTTP/S Requests easily

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BodyProvider

type BodyProvider interface {
	// ContentType returns the Content-Type of the body.
	ContentType() string
	// Body returns the io.Reader body.
	Body() (io.Reader, error)
}

BodyProvider provides Body content for http.Request attachment.

type BodyResponse

type BodyResponse interface {
	// Decode decodes the response into the value pointed to by v.
	Decode(resp io.Reader, v interface{}) error
}

BodyResponse decodes http responses into struct values.

type Requist

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

Requist struct Encapsulate an HTTP(S) requests builder and sender

func New

func New(baseURL string) *Requist

New function

@param baseURL
@return Requist class pointer

func (*Requist) AddHeader

func (r *Requist) AddHeader(key, value string) *Requist

Add adds the key, value pair in Headers, appending values for existing keys to the key's values. Header keys are canonicalized.

func (*Requist) AddQueryParam

func (r *Requist) AddQueryParam(key, value string) *Requist

AddQueryParam adds the key, value tuples in QueryParams, appending values for existing keys

func (*Requist) Base

func (r *Requist) Base(base string) *Requist

Base sets base url to use for a client

func (*Requist) Body

func (r *Requist) Body(body io.Reader) *Requist

Body ... This func sets the body before make the efective Request.

func (*Requist) BodyAsForm

func (r *Requist) BodyAsForm(body interface{}) *Requist

BodyAsForm sets the Requests's body from a formProvider

func (*Requist) BodyAsJSON

func (r *Requist) BodyAsJSON(body interface{}) *Requist

BodyAsJSON sets the Requests's body from a jsonProvider

func (*Requist) BodyProvider

func (r *Requist) BodyProvider(body BodyProvider) *Requist

BodyProvider sets the Requests's body provider from original BodyProvider interface{}.

func (*Requist) Connect

func (r *Requist) Connect(path string, successV, failureV interface{}) (*Requist, error)

This implement CONNECT HTTP Method

func (*Requist) DelHeader

func (r *Requist) DelHeader(key, value string) *Requist

Remove the key, value pair in Headers

func (*Requist) DelQueryParam

func (r *Requist) DelQueryParam(key, value string) *Requist

Remove the key, value pair in QueryParams

func (*Requist) Delete

func (r *Requist) Delete(path string, successV, failureV interface{}) (*Requist, error)

This implement DELETE HTTP Method

func (*Requist) Get

func (r *Requist) Get(path string, successV, failureV interface{}) (*Requist, error)

This implement GET HTTP Method

func (*Requist) GetBasicAuth

func (r *Requist) GetBasicAuth() string

GetBasicAuth return the auth stored at the Requist class

func (*Requist) Head

func (r *Requist) Head(path string, successV, failureV interface{}) (*Requist, error)

This implement HEAD HTTP Method

func (*Requist) Method

func (r *Requist) Method(method string) *Requist

Method set HTTP Method to execute

func (*Requist) New

func (r *Requist) New(baseURL string) *Requist

New class function

@param Requist class pointer, previous existing instance
@return Requist class pointer who clone some data from passed class

func (*Requist) Options

func (r *Requist) Options(path string, successV, failureV interface{}) (*Requist, error)

This implement OPTIONS HTTP Method

func (*Requist) Patch

func (r *Requist) Patch(path string, successV, failureV interface{}) (*Requist, error)

This implement PATCH HTTP Method

func (*Requist) Path

func (r *Requist) Path(path string) *Requist

Path sets request path to use in next request

func (*Requist) Post

func (r *Requist) Post(path string, successV, failureV interface{}) (*Requist, error)

This implement POST HTTP Method

func (*Requist) Put

func (r *Requist) Put(path string, successV, failureV interface{}) (*Requist, error)

This implement PUT HTTP Method

func (*Requist) Request

func (r *Requist) Request(successV, failureV interface{}) (*Requist, error)

Request ... Here it's where the magic show up

func (*Requist) SetBasicAuth

func (r *Requist) SetBasicAuth(username, password string) *Requist

SetBasicAuth sets the Authorization header to use HTTP Basic Authentication

func (*Requist) SetHeader

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

Set sets the key, value pair in Headers, replacing existing values associated with key. Header keys are canonicalized.

func (*Requist) SetQueryParam

func (r *Requist) SetQueryParam(key, value string) *Requist

SetQueryParam set the key, value tuples in params to

func (*Requist) StatusCode

func (r *Requist) StatusCode() int

StatusCode return the HTTP StatusCode from last request

func (*Requist) Trace

func (r *Requist) Trace(path string, successV, failureV interface{}) (*Requist, error)

This implement TRACE HTTP Method

Jump to

Keyboard shortcuts

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