httpclient

package module
v0.0.0-...-996a918 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2020 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUrlIsEmpty    = errors.New("url is empty")
	ErrLoggerIsEmpty = errors.New("logger is empty")
)

Functions

This section is empty.

Types

type Builder

type Builder struct {
	Url     string
	Method  string
	Path    string
	Headers map[string]string
	Queries url.Values
	// contains filtered or unexported fields
}

Builder is a object that help to build fluent style API.

func New

func New() *Builder

New returns an new Builder object.

func (*Builder) BasicAuth

func (b *Builder) BasicAuth(username, password string) *Builder

func (*Builder) Body

func (b *Builder) Body(v interface{}) *Builder

Body convert v to []byte and using ad http request body

func (*Builder) ContentType

func (b *Builder) ContentType(mimeType string) *Builder

func (*Builder) Debug

func (b *Builder) Debug(debug bool) *Builder

func (*Builder) Delete

func (b *Builder) Delete(url string) *Builder

Delete uses the http DELETE method with provided url and returns Builder.

func (*Builder) Do

func (b *Builder) Do() (*http.Response, error)

Do executes the http request client and returns http.Response and error.

func (*Builder) Get

func (b *Builder) Get(url string) *Builder

Get uses the http GET method with provided url and returns Builder.

func (*Builder) Head

func (b *Builder) Head(url string) *Builder

Head uses the http HEAD method with provided url and returns Builder.

func (*Builder) Header

func (b *Builder) Header(key, value string) *Builder

Header sets http header key with value and returns Builder.

func (*Builder) JsonBody

func (b *Builder) JsonBody(v interface{}) *Builder

func (*Builder) Logger

func (b *Builder) Logger(log *log.Logger) *Builder

Logger sets the provided logger and returns Builder.

func (*Builder) Post

func (b *Builder) Post(url string) *Builder

Post uses the http POST method with provided url and returns Builder.

func (*Builder) Put

func (b *Builder) Put(url string) *Builder

Put uses the http PUT method with provided url and returns Builder.

func (*Builder) QueryAdd

func (b *Builder) QueryAdd(key, value string) *Builder

QueryAdd adds http QUERY parameter key with value and returns Builder.

func (*Builder) QuerySet

func (b *Builder) QuerySet(key string, value string) *Builder

QuerySet sets http QUERY parameter key with value returns Builder.

func (*Builder) StringBody

func (b *Builder) StringBody(v string) *Builder

func (*Builder) Timeout

func (b *Builder) Timeout(timeout time.Duration) *Builder

func (*Builder) UnmarshalJson

func (b *Builder) UnmarshalJson(v interface{}) (*http.Response, error)

UnmarshalJson executes the http request client and returns http.Response and error.

func (*Builder) UrlEncodedBody

func (b *Builder) UrlEncodedBody(v map[string]string) *Builder

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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