Documentation ¶
Index ¶
- Variables
- func Do(req *YakHttpRequest) (*http.Response, error)
- func GetAllBody(raw interface{}) []byte
- func GetClient(session interface{}) *http.Client
- type HttpOption
- func Body(value interface{}) HttpOption
- func Cookie(value interface{}) HttpOption
- func FakeUserAgent() HttpOption
- func GetParams(i interface{}) HttpOption
- func Header(key, value interface{}) HttpOption
- func JsonBody(value interface{}) HttpOption
- func NoRedirect() HttpOption
- func PostParams(i interface{}) HttpOption
- func RedirectHandler(c func(r *http.Request, vias []*http.Request) bool) HttpOption
- func Session(value interface{}) HttpOption
- func UserAgent(value interface{}) HttpOption
- func YakHttpConfig_Proxy(values ...string) HttpOption
- type YakHttpRequest
- type YakHttpResponse
Constants ¶
This section is empty.
Variables ¶
View Source
var ClientPool sync.Map
View Source
var HttpExports = map[string]interface{}{ "Raw": rawRequest, "Get": func(url string, opts ...HttpOption) (*YakHttpResponse, error) { return httpRequest("GET", url, opts...) }, "Post": func(url string, opts ...HttpOption) (*YakHttpResponse, error) { return httpRequest("POST", url, opts...) }, "Request": httpRequest, "Do": Do, "NewRequest": NewHttpNewRequest, "GetAllBody": GetAllBody, "dump": dump, "show": httpShow, "dumphead": dumphead, "showhead": func(i interface{}) { rsp, err := dumphead(i) if err != nil { log.Errorf("show failed: %s", err) return } fmt.Println(string(rsp)) }, "ua": UserAgent, "useragent": UserAgent, "fakeua": FakeUserAgent, "header": Header, "cookie": Cookie, "body": Body, "json": JsonBody, "params": GetParams, "postparams": PostParams, "proxy": YakHttpConfig_Proxy, "timeout": yakHttpConfig_Timeout, "redirect": RedirectHandler, "noredirect": NoRedirect, "session": Session, "uarand": _getuarand, }
View Source
var NewHttpNewRequest = func(method, url string, opts ...HttpOption) (*YakHttpRequest, error) { req, err := http.NewRequest(method, url, nil) if err != nil { return nil, err } rawReq := &YakHttpRequest{ Request: req, } for _, op := range opts { op(rawReq) } return rawReq, nil }
Functions ¶
func GetAllBody ¶
func GetAllBody(raw interface{}) []byte
Types ¶
type HttpOption ¶
type HttpOption func(req *YakHttpRequest)
func Body ¶
func Body(value interface{}) HttpOption
func Cookie ¶
func Cookie(value interface{}) HttpOption
func FakeUserAgent ¶
func FakeUserAgent() HttpOption
func Header ¶
func Header(key, value interface{}) HttpOption
func JsonBody ¶
func JsonBody(value interface{}) HttpOption
func NoRedirect ¶
func NoRedirect() HttpOption
func RedirectHandler ¶
func Session ¶
func Session(value interface{}) HttpOption
func UserAgent ¶
func UserAgent(value interface{}) HttpOption
func YakHttpConfig_Proxy ¶ added in v1.2.6
func YakHttpConfig_Proxy(values ...string) HttpOption
type YakHttpRequest ¶
type YakHttpResponse ¶
func (*YakHttpResponse) Data ¶
func (y *YakHttpResponse) Data() string
func (*YakHttpResponse) GetHeader ¶
func (y *YakHttpResponse) GetHeader(key string) string
func (*YakHttpResponse) Json ¶
func (y *YakHttpResponse) Json() interface{}
func (*YakHttpResponse) Raw ¶
func (y *YakHttpResponse) Raw() []byte
Click to show internal directories.
Click to hide internal directories.