httpClient

package
v0.0.0-...-6a52fcc Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GetMethod     = "GET"
	PostMethod    = "POST"
	PutMethod     = "PUT"
	DeleteMethod  = "DELETE"
	PatchMethod   = "PATCH"
	HeadMethod    = "HEAD"
	OptionsMethod = "OPTIONS"
)

Variables

This section is empty.

Functions

func NewHttpClient

func NewHttpClient(config *Config) *http.Client

Types

type Config

type Config struct{}

type HttpRequest

type HttpRequest struct {
	URL    string
	Method string
	Query  url.Values
	Header http.Header
	Body   io.Reader
	// contains filtered or unexported fields
}

func BuildReq

func BuildReq() *HttpRequest

func (*HttpRequest) Client

func (request *HttpRequest) Client() *http.Client

func (*HttpRequest) Delete

func (request *HttpRequest) Delete(url string) *HttpRequest

func (*HttpRequest) Execute

func (request *HttpRequest) Execute() (*HttpResponse, error)

func (*HttpRequest) Get

func (request *HttpRequest) Get(url string) *HttpRequest

func (*HttpRequest) Head

func (request *HttpRequest) Head(url string) *HttpRequest

func (*HttpRequest) Options

func (request *HttpRequest) Options(url string) *HttpRequest

func (*HttpRequest) Patch

func (request *HttpRequest) Patch(url string) *HttpRequest

func (*HttpRequest) Post

func (request *HttpRequest) Post(url string) *HttpRequest

func (*HttpRequest) Put

func (request *HttpRequest) Put(url string) *HttpRequest

func (*HttpRequest) SetBody

func (request *HttpRequest) SetBody(body io.Reader) *HttpRequest

func (*HttpRequest) SetClient

func (request *HttpRequest) SetClient(config *Config) *HttpRequest

func (*HttpRequest) SetContext

func (request *HttpRequest) SetContext(context context.Context) *HttpRequest

func (*HttpRequest) SetHeader

func (request *HttpRequest) SetHeader(header, value string) *HttpRequest

func (*HttpRequest) SetHeaders

func (request *HttpRequest) SetHeaders(headers map[string]string) *HttpRequest

func (*HttpRequest) SetQueryParam

func (request *HttpRequest) SetQueryParam(param, value string) *HttpRequest

func (*HttpRequest) SetQueryParams

func (request *HttpRequest) SetQueryParams(params map[string]string) *HttpRequest

type HttpResponse

type HttpResponse struct {
	Response *http.Response
}

func NewHttpResponse

func NewHttpResponse(res *http.Response) *HttpResponse

func (*HttpResponse) Bind

func (response *HttpResponse) Bind(s interface{}) error

func (*HttpResponse) Body

func (response *HttpResponse) Body() io.ReadCloser

func (*HttpResponse) Cookies

func (response *HttpResponse) Cookies() []*http.Cookie

func (*HttpResponse) Header

func (response *HttpResponse) Header() http.Header

func (*HttpResponse) IsError

func (response *HttpResponse) IsError() bool

func (*HttpResponse) IsSuccess

func (response *HttpResponse) IsSuccess() bool

func (*HttpResponse) Status

func (response *HttpResponse) Status() string

func (*HttpResponse) StatusCode

func (response *HttpResponse) StatusCode() int

Jump to

Keyboard shortcuts

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