Documentation ¶
Index ¶
- Constants
- Variables
- func GetReqData(d map[string]string) string
- func SetTimeout(t time.Duration)
- type DataType
- type HeaderDto
- type HttpResultDto
- func Get(requestUrl string, options *Options) (*HttpResultDto, error)
- func NewHttpResultDto() *HttpResultDto
- func Post(requestUrl string, options *Options) (*HttpResultDto, error)
- func SimpleGet(requestUrl string) (*HttpResultDto, error)
- func SimplePost(requestUrl string, data map[string]string) (*HttpResultDto, error)
- type Options
- func (o *Options) WithCookie(cookie map[string]string) *Options
- func (o *Options) WithData(data map[string]string) *Options
- func (o *Options) WithDataType(t DataType) *Options
- func (o *Options) WithHeader(header *HeaderDto) *Options
- func (o *Options) WithJsonData(data interface{}) *Options
- func (o *Options) WithProxy(proxy *ProxyDto) *Options
- func (o *Options) WithQuery(query map[string]string) *Options
- func (o *Options) WithTimeout(timeout time.Duration) *Options
- type ProxyDto
Constants ¶
View Source
const CONTENT_TYPE_FORM = "application/x-www-form-urlencoded"
View Source
const CONTENT_TYPE_JSON = "application/json"
View Source
const HTTP_CODE_OK = 200
View Source
const HTTP_USER_AGENT = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.105 Safari/537.36"
View Source
const PROTO_HTTP = "http"
View Source
const PROTO_HTTPS = "https"
View Source
const PROTO_SOCKS4 = "socks4"
View Source
const PROTO_SOCKS4A = "socks4a"
View Source
const PROTO_SOCKS5 = "socks5"
View Source
const PROTO_SS = "ss"
Variables ¶
View Source
var DefaultTimeout = time.Second * 5
View Source
var PROTO_LIST = []string{ PROTO_HTTP, PROTO_SOCKS5, PROTO_HTTPS, PROTO_SOCKS4, PROTO_HTTPS, PROTO_SS, }
protocols
Functions ¶
func SetTimeout ¶ added in v1.2.1
Types ¶
type DataType ¶ added in v1.2.2
type DataType string
const DEFAULT DataType = ""
const FORM DataType = "form"
const JSON DataType = "json"
type HttpResultDto ¶
type HttpResultDto struct { Body string HttpCode int ContentLength int64 Header map[string][]string Cookies map[string]string }
func Get ¶ added in v1.2.0
func Get(requestUrl string, options *Options) (*HttpResultDto, error)
Get with options
func NewHttpResultDto ¶
func NewHttpResultDto() *HttpResultDto
func Post ¶ added in v1.2.0
func Post(requestUrl string, options *Options) (*HttpResultDto, error)
Post Post with options
func SimpleGet ¶ added in v1.2.2
func SimpleGet(requestUrl string) (*HttpResultDto, error)
SimpleGet Simple Get
func SimplePost ¶ added in v1.2.2
func SimplePost(requestUrl string, data map[string]string) (*HttpResultDto, error)
SimplePost Post
func (HttpResultDto) String ¶
func (s HttpResultDto) String() string
type Options ¶ added in v1.2.2
type Options struct { Header *HeaderDto Cookie map[string]string Proxy *ProxyDto Timeout time.Duration Data map[string]string Query map[string]string JsonData interface{} DataType DataType }
func NewOptions ¶ added in v1.2.2
func NewOptions() *Options
func (*Options) WithCookie ¶ added in v1.2.2
func (*Options) WithDataType ¶ added in v1.2.2
func (*Options) WithHeader ¶ added in v1.2.2
func (*Options) WithJsonData ¶ added in v1.2.2
Click to show internal directories.
Click to hide internal directories.