request

package
v0.0.0-...-3c045af Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2021 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultRedirectCb

func DefaultRedirectCb(req *http.Request, via []*http.Request) error

func DisableRedirectCb

func DisableRedirectCb(req *http.Request, via []*http.Request) error

func IsHtml

func IsHtml(data []byte) bool

func IsJson

func IsJson(data []byte) bool

func JsonConvert

func JsonConvert(data []byte, v interface{}) error

func JsonErr

func JsonErr(err error, data []byte)

func JsonToMap

func JsonToMap(data []byte) map[string]interface{}

func JsonToStruct

func JsonToStruct(data []byte, v interface{})

func PanicIf

func PanicIf(err error)

func ReactIf

func ReactIf(err error, f func())

Types

type Clienter

type Clienter interface {
	Do(req *HttpReq) *HttpResp
}

type HttpClient

type HttpClient struct {
	Cl *http.Client
}
var DefaultClient *HttpClient

func NewClient

func NewClient() *HttpClient

func (*HttpClient) Do

func (c *HttpClient) Do(req *HttpReq) *HttpResp

func (*HttpClient) Get

func (c *HttpClient) Get(url string) *HttpResp

func (*HttpClient) LoadCookies

func (c *HttpClient) LoadCookies(filepath string) error

func (*HttpClient) Post

func (c *HttpClient) Post(url string, body io.Reader) *HttpResp

func (*HttpClient) PostForm

func (c *HttpClient) PostForm(url, body string) *HttpResp

func (*HttpClient) PostJson

func (c *HttpClient) PostJson(url, body string) *HttpResp

func (*HttpClient) StoreCookies

func (c *HttpClient) StoreCookies(filepath string) error

type HttpReq

type HttpReq struct {
	*http.Request
}

func Get

func Get(url string) *HttpReq

func NewRequest

func NewRequest(method, url string, body io.Reader) *HttpReq

func Post

func Post(url string, body io.Reader) *HttpReq

func PostForm

func PostForm(url string, body string) *HttpReq

func PostJson

func PostJson(url string, body string) *HttpReq

func (*HttpReq) Do

func (r *HttpReq) Do(c Clienter) *HttpResp

func (*HttpReq) Form

func (r *HttpReq) Form() *HttpReq

func (*HttpReq) Json

func (r *HttpReq) Json() *HttpReq

func (*HttpReq) Origin

func (r *HttpReq) Origin(origin string) *HttpReq

func (*HttpReq) Referer

func (r *HttpReq) Referer(referer string) *HttpReq

type HttpResp

type HttpResp struct {
	*http.Response

	Err error
	// contains filtered or unexported fields
}

func (*HttpResp) Bytes

func (resp *HttpResp) Bytes() []byte

func (*HttpResp) Reader

func (resp *HttpResp) Reader() *bytes.Reader

func (*HttpResp) String

func (resp *HttpResp) String() string

Jump to

Keyboard shortcuts

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