Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseJsonResponse ¶
Types ¶
type ContentType ¶
type ContentType = string
const ( ContentTypeJson ContentType = "application/json" ContentTypeForm ContentType = "application/x-www-form-urlencoded" ContentTypeFileStream ContentType = "application/octet-stream" ContentTypeMultipart ContentType = "multipart/form-data" ContentTypeTextPlain ContentType = "text/plain" ContentTypeTextHtml ContentType = "text/html" ContentTypeTextXml ContentType = "text/xml" ContentTypeTextYaml ContentType = "text/yaml" ContentTypeTextCsv ContentType = "text/csv" ContentTypeImagePng ContentType = "image/png" ContentTypeImageJpeg ContentType = "image/jpeg" ContentTypeImageGif ContentType = "image/gif" )
type Request ¶
type Request interface {
SetUrl(path string) Request
SetMethod(method string) Request
SetBearerToken(token string) Request
SetUserAgent(userAgent string) Request
SetAccept(accept string) Request
SetHeader(key, value string) Request
SetJsonBody(ptr any) Request
SetMultiPartBody(multipartField, multipartName string, multiWriter io.Reader, others map[string]string) Request
SetCookie(cookieKey, cookieValue string) Request
// contains filtered or unexported methods
}
func NewGetRequest ¶
func NewPostRequest ¶
func NewRequest ¶
func NewRequest() Request
type Response ¶
type Response interface {
Error() error
Result() (status int, body []byte, err error)
StringResult() (status int, body string, err error)
BindJsonResult(receiver any) (status int, err error)
GetHeader(key string, defaultVal ...string) (val string)
GetBearerToken() (token string)
GetCookie(cookieName string) (ck *http.Cookie)
GetStatusCode() int
GetBody() (body []byte)
BindJsonBody(receiver any) (err error)
}
type UserAgent ¶
type UserAgent = string
const ( Curl UserAgent = "curl/7.64.1" Postman UserAgent = "PostmanRuntime/7.26.8" ChromeOSX UserAgent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36" Safari UserAgent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.1 Safari/605.1.15" Firefox UserAgent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:109.0) Gecko/20100101 Firefox/119.0" )
Click to show internal directories.
Click to hide internal directories.