Documentation ¶
Overview ¶
Index ¶
- Variables
- func AutoLogin(url, app_key, user_name, pass_word string) (string, *http.Response, error)
- func ClearData(size uintptr, ptr unsafe.Pointer)
- func DeleteType(name string)
- func DownloadFile(url_str string, out_file string, conn_timeout, rw_timeout time.Duration) error
- func DownloadTextFile(url_str string, conn_timeout, rw_timeout time.Duration) (int, []string, error)
- func DownloadURL(url_str string, conn_timeout, rw_timeout time.Duration) (int, []string, error)
- func GetHttpRemoteAddr(req *http.Request) string
- func GetIPByDomain(query_name string, args ...interface{}) (string, []string, string, error)
- func GetIPByURL(url_str string) (string, error)
- func GetMacByIP(ip_text string) (string, error)
- func GetMacByIP_arp(ip_text string) (string, error)
- func GetMacByIP_file(ip_text string) (string, error)
- func GetMsgAllType() []string
- func GetMsgType(name string) (reflect.Type, error)
- func GetPublicIP() string
- func HttpRequest(method, url string, is_cookie bool, params map[string]string, body interface{}, ...) (int, *http.Response, []byte, error)
- func HttpRequestA(method, url string, is_cookie bool, result interface{}) (int, *http.Response, []byte, error)
- func HttpRequestB(method, url string, is_cookie bool) (int, *http.Response, []byte, error)
- func HttpRequestBB(method, url string, is_cookie bool, body interface{}, result interface{}) (int, *http.Response, []byte, error)
- func HttpRequestBC(method, url string, is_cookie bool, body interface{}, cookies []*http.Cookie, ...) (int, *http.Response, []byte, error)
- func HttpRequestBD(method, url string, is_cookie bool, body interface{}, ...) (int, *http.Response, []byte, error)
- func HttpRequestBHB(method, url string, is_cookie bool, body interface{}, header map[string]string, ...) (int, *http.Response, []byte, error)
- func HttpRequestBHC(method, url string, is_cookie bool, body interface{}, cookies []*http.Cookie, ...) (int, *http.Response, []byte, error)
- func HttpRequestBHD(method, url string, is_cookie bool, body interface{}, header map[string]string, ...) (int, *http.Response, []byte, error)
- func HttpRequestHA(method, url string, is_cookie bool, header map[string]string, ...) (int, *http.Response, []byte, error)
- func HttpRequestHB(method, url string, is_cookie bool, header map[string]string) (int, *http.Response, []byte, error)
- func HttpRequestPB(method, url string, is_cookie bool, params map[string]string, ...) (int, *http.Response, []byte, error)
- func HttpRequestPC(method, url string, is_cookie bool, params map[string]string, ...) (int, *http.Response, []byte, error)
- func HttpRequestPD(method, url string, is_cookie bool, params map[string]string, ...) (int, *http.Response, []byte, error)
- func HttpRequestPHB(method, url string, is_cookie bool, params map[string]string, ...) (int, *http.Response, []byte, error)
- func HttpRequestPHC(method, url string, is_cookie bool, params map[string]string, ...) (int, *http.Response, []byte, error)
- func HttpRequestPHD(method, url string, is_cookie bool, params map[string]string, ...) (int, *http.Response, []byte, error)
- func OpenWebManager(ports ...int) *http.ServeMux
- func RegisterType(typ reflect.Type)
- func SetDefaultSetting(setting THttpSettings)
- func SetDefaultSettingByTimeout(connectTimeout, readWriteTimeout time.Duration)
- func SimpleHttpGet(url_str string, conn_timeout, rw_timeout time.Duration) (int, []byte, error)
- func SimpleHttpPost(url_str string, body interface{}, conn_timeout, rw_timeout time.Duration) (int, []byte, error)
- func TimeoutDialer(cTimeout time.Duration, rwTimeout time.Duration) func(net, addr string) (c net.Conn, err error)
- type Filter
- type FilterChain
- type GobConnection
- type THttpRequest
- func (b *THttpRequest) AddFilters(fcs ...FilterChain) *THttpRequest
- func (b *THttpRequest) Body(data interface{}) *THttpRequest
- func (b *THttpRequest) Bytes() ([]byte, error)
- func (b *THttpRequest) Debug(isdebug bool) *THttpRequest
- func (b *THttpRequest) DoRequest() (resp *http.Response, err error)
- func (b *THttpRequest) DoRequestWithCtx(ctx context.Context) (resp *http.Response, err error)
- func (b *THttpRequest) DumpBody(isdump bool) *THttpRequest
- func (b *THttpRequest) DumpRequest() []byte
- func (b *THttpRequest) GetRequest() *http.Request
- func (b *THttpRequest) GetResponse() *http.Response
- func (b *THttpRequest) Header(key, value string) *THttpRequest
- func (b *THttpRequest) JSONBody(obj interface{}) (*THttpRequest, error)
- func (b *THttpRequest) Param(key, value string) *THttpRequest
- func (b *THttpRequest) PostFile(formname, filename string) *THttpRequest
- func (b *THttpRequest) Response() (*http.Response, error)
- func (b *THttpRequest) Retries(times int) *THttpRequest
- func (b *THttpRequest) RetryDelay(delay time.Duration) *THttpRequest
- func (b *THttpRequest) SetBasicAuth(username, password string) *THttpRequest
- func (b *THttpRequest) SetCheckRedirect(redirect func(req *http.Request, via []*http.Request) error) *THttpRequest
- func (b *THttpRequest) SetCookie(cookie *http.Cookie) *THttpRequest
- func (b *THttpRequest) SetEnableCookie(enable bool) *THttpRequest
- func (b *THttpRequest) SetFilters(fcs ...FilterChain) *THttpRequest
- func (b *THttpRequest) SetHost(host string) *THttpRequest
- func (b *THttpRequest) SetProtocolVersion(vers string) *THttpRequest
- func (b *THttpRequest) SetProxy(proxy func(*http.Request) (*url.URL, error)) *THttpRequest
- func (b *THttpRequest) SetTLSClientConfig(config *tls.Config) *THttpRequest
- func (b *THttpRequest) SetTimeout(connectTimeout, readWriteTimeout time.Duration) *THttpRequest
- func (b *THttpRequest) SetTransport(transport http.RoundTripper) *THttpRequest
- func (b *THttpRequest) SetUserAgent(useragent string) *THttpRequest
- func (b *THttpRequest) Setting(setting THttpSettings) *THttpRequest
- func (b *THttpRequest) StatusCode() (int, error)
- func (b *THttpRequest) String() (string, error)
- func (b *THttpRequest) ToFile(filename string) error
- func (b *THttpRequest) ToJSON(v interface{}) error
- func (b *THttpRequest) ToXML(v interface{}) error
- func (b *THttpRequest) ToYAML(v interface{}) error
- func (b *THttpRequest) XMLBody(obj interface{}) (*THttpRequest, error)
- func (b *THttpRequest) YAMLBody(obj interface{}) (*THttpRequest, error)
- type THttpSettings
- type TIPData
- type TPingResult
Constants ¶
This section is empty.
Variables ¶
var (
Errortype = errors.New("type not register")
)
var WebAutoTestAPI func(w http.ResponseWriter, r *http.Request, re map[string]interface{}) map[string]interface{}
var WebManagerAPI func(w http.ResponseWriter, r *http.Request)
Functions ¶
func DeleteType ¶
func DeleteType(name string)
func DownloadFile ¶
func DownloadTextFile ¶
func DownloadURL ¶ added in v1.1.1
func GetIPByDomain ¶
通过域名得到IP地址,返回:真实的域名,IP列表,域名服务器,错误
func GetMacByIP ¶
func GetMacByIP_arp ¶
func GetMacByIP_file ¶
通过IP地址得到Mac地址,如果通过网关访问,得到的将是网关的mac。
func GetMsgAllType ¶
func GetMsgAllType() []string
func HttpRequest ¶
func HttpRequestA ¶
func HttpRequestA(method, url string, is_cookie bool, result interface{}) (int, *http.Response, []byte, error)
单句调用Http请求(有返回值)
func HttpRequestB ¶
单句调用Http请求(无返回值)
func HttpRequestBB ¶
func HttpRequestBB(method, url string, is_cookie bool, body interface{}, result interface{}) (int, *http.Response, []byte, error)
单句调用Http请求(带Body,有返回值)
func HttpRequestBC ¶
func HttpRequestBC(method, url string, is_cookie bool, body interface{}, cookies []*http.Cookie, result interface{}) (int, *http.Response, []byte, error)
单句调用Http请求(带Body,Cookies,有返回值)
func HttpRequestBD ¶
func HttpRequestBD(method, url string, is_cookie bool, body interface{}, username, password string, result interface{}) (int, *http.Response, []byte, error)
单句调用Http请求(带Body,用户密码,有返回值)
func HttpRequestBHB ¶
func HttpRequestBHB(method, url string, is_cookie bool, body interface{}, header map[string]string, result interface{}) (int, *http.Response, []byte, error)
单句调用Http请求(带Body,Header,有返回值)
func HttpRequestBHC ¶
func HttpRequestBHC(method, url string, is_cookie bool, body interface{}, cookies []*http.Cookie, header map[string]string, result interface{}) (int, *http.Response, []byte, error)
单句调用Http请求(带Body,Cookies,Header,有返回值)
func HttpRequestBHD ¶
func HttpRequestBHD(method, url string, is_cookie bool, body interface{}, header map[string]string, username, password string, result interface{}) (int, *http.Response, []byte, error)
单句调用Http请求(带Body,Header,用户密码,有返回值)
func HttpRequestHA ¶
func HttpRequestHA(method, url string, is_cookie bool, header map[string]string, result interface{}) (int, *http.Response, []byte, error)
单句调用Http请求(带Header,有返回值)
func HttpRequestHB ¶
func HttpRequestHB(method, url string, is_cookie bool, header map[string]string) (int, *http.Response, []byte, error)
单句调用Http请求(带Header,无返回值)
func HttpRequestPB ¶
func HttpRequestPB(method, url string, is_cookie bool, params map[string]string, result interface{}) (int, *http.Response, []byte, error)
单句调用Http请求(带Params,有返回值)
func HttpRequestPC ¶
func HttpRequestPC(method, url string, is_cookie bool, params map[string]string, cookies []*http.Cookie, result interface{}) (int, *http.Response, []byte, error)
单句调用Http请求(带Params,Cookies,有返回值)
func HttpRequestPD ¶
func HttpRequestPD(method, url string, is_cookie bool, params map[string]string, username, password string, result interface{}) (int, *http.Response, []byte, error)
单句调用Http请求(带Params,用户密码,有返回值)
func HttpRequestPHB ¶
func HttpRequestPHB(method, url string, is_cookie bool, params map[string]string, header map[string]string, result interface{}) (int, *http.Response, []byte, error)
单句调用Http请求(带Params,Header,有返回值)
func HttpRequestPHC ¶
func HttpRequestPHC(method, url string, is_cookie bool, params map[string]string, cookies []*http.Cookie, header map[string]string, result interface{}) (int, *http.Response, []byte, error)
单句调用Http请求(带Params,Cookies,Header,有返回值)
func HttpRequestPHD ¶
func HttpRequestPHD(method, url string, is_cookie bool, params map[string]string, header map[string]string, username, password string, result interface{}) (int, *http.Response, []byte, error)
单句调用Http请求(带Params,Header,用户密码,有返回值)
func OpenWebManager ¶
func RegisterType ¶
func SetDefaultSetting ¶
func SetDefaultSetting(setting THttpSettings)
SetDefaultSetting Overwrite default settings
func SimpleHttpGet ¶
func SimpleHttpPost ¶
Types ¶
type FilterChain ¶
type GobConnection ¶
type GobConnection interface { Read() (msg message, err error) Write(msg interface{}) (err error) Close() error LocalAddr() net.Addr RemoteAddr() net.Addr }
func NewGobConnection ¶
func NewGobConnection(conn net.Conn) GobConnection
type THttpRequest ¶
type THttpRequest struct {
// contains filtered or unexported fields
}
THTTPRequest provides more useful methods for requesting one url than http.Request.
func HttpDelete ¶
func HttpDelete(url string) *THttpRequest
Delete returns *THttpRequest DELETE method.
func HttpHead ¶
func HttpHead(url string) *THttpRequest
Head returns *THttpRequest with HEAD method.
func HttpPost ¶
func HttpPost(url string) *THttpRequest
Post returns *THttpRequest with POST method.
func NewRequest ¶
func NewRequest(rawurl, method string) *THttpRequest
NewTRequest return *THttpRequest with specific method
func (*THttpRequest) AddFilters ¶
func (b *THttpRequest) AddFilters(fcs ...FilterChain) *THttpRequest
AddFilters adds filter
func (*THttpRequest) Body ¶
func (b *THttpRequest) Body(data interface{}) *THttpRequest
Body adds request raw body. it supports string and []byte.
func (*THttpRequest) Bytes ¶
func (b *THttpRequest) Bytes() ([]byte, error)
Bytes returns the body []byte in response. it calls Response inner.
func (*THttpRequest) Debug ¶
func (b *THttpRequest) Debug(isdebug bool) *THttpRequest
Debug sets show debug or not when executing request.
func (*THttpRequest) DoRequest ¶
func (b *THttpRequest) DoRequest() (resp *http.Response, err error)
DoRequest executes client.Do
func (*THttpRequest) DoRequestWithCtx ¶
func (*THttpRequest) DumpBody ¶
func (b *THttpRequest) DumpBody(isdump bool) *THttpRequest
DumpBody setting whether need to Dump the Body.
func (*THttpRequest) DumpRequest ¶
func (b *THttpRequest) DumpRequest() []byte
DumpRequest return the DumpRequest
func (*THttpRequest) GetRequest ¶
func (b *THttpRequest) GetRequest() *http.Request
GetRequest return the request object
func (*THttpRequest) GetResponse ¶
func (b *THttpRequest) GetResponse() *http.Response
Response executes request client gets response mannually.
func (*THttpRequest) Header ¶
func (b *THttpRequest) Header(key, value string) *THttpRequest
Header add header item string in request.
func (*THttpRequest) JSONBody ¶
func (b *THttpRequest) JSONBody(obj interface{}) (*THttpRequest, error)
JSONBody adds request raw body encoding by JSON.
func (*THttpRequest) Param ¶
func (b *THttpRequest) Param(key, value string) *THttpRequest
Param adds query param in to request. params build query string as ?key1=value1&key2=value2...
func (*THttpRequest) PostFile ¶
func (b *THttpRequest) PostFile(formname, filename string) *THttpRequest
PostFile add a post file to the request
func (*THttpRequest) Response ¶
func (b *THttpRequest) Response() (*http.Response, error)
Response executes request client gets response mannually.
func (*THttpRequest) Retries ¶
func (b *THttpRequest) Retries(times int) *THttpRequest
Retries sets Retries times. default is 0 means no retried. -1 means retried forever. others means retried times.
func (*THttpRequest) RetryDelay ¶
func (b *THttpRequest) RetryDelay(delay time.Duration) *THttpRequest
RetryDelay sets the time to sleep between reconnection attempts
func (*THttpRequest) SetBasicAuth ¶
func (b *THttpRequest) SetBasicAuth(username, password string) *THttpRequest
SetBasicAuth sets the request's Authorization header to use HTTP Basic Authentication with the provided username and password.
func (*THttpRequest) SetCheckRedirect ¶
func (b *THttpRequest) SetCheckRedirect(redirect func(req *http.Request, via []*http.Request) error) *THttpRequest
SetCheckRedirect specifies the policy for handling redirects.
If CheckRedirect is nil, the Client uses its default policy, which is to stop after 10 consecutive requests.
func (*THttpRequest) SetCookie ¶
func (b *THttpRequest) SetCookie(cookie *http.Cookie) *THttpRequest
SetCookie add cookie into request.
func (*THttpRequest) SetEnableCookie ¶
func (b *THttpRequest) SetEnableCookie(enable bool) *THttpRequest
是否会话保持,保存Cookied
func (*THttpRequest) SetFilters ¶
func (b *THttpRequest) SetFilters(fcs ...FilterChain) *THttpRequest
SetFilters will use the filter as the invocation filters
func (*THttpRequest) SetHost ¶
func (b *THttpRequest) SetHost(host string) *THttpRequest
SetHost set the request host
func (*THttpRequest) SetProtocolVersion ¶
func (b *THttpRequest) SetProtocolVersion(vers string) *THttpRequest
SetProtocolVersion Set the protocol version for incoming requests. Client requests always use HTTP/1.1.
func (*THttpRequest) SetProxy ¶
func (b *THttpRequest) SetProxy(proxy func(*http.Request) (*url.URL, error)) *THttpRequest
SetProxy set the http proxy example:
func(req *http.Request) (*url.URL, error) { u, _ := url.ParseRequestURI("http://127.0.0.1:8118") return u, nil }
func (*THttpRequest) SetTLSClientConfig ¶
func (b *THttpRequest) SetTLSClientConfig(config *tls.Config) *THttpRequest
SetTLSClientConfig sets tls connection configurations if visiting https url.
func (*THttpRequest) SetTimeout ¶
func (b *THttpRequest) SetTimeout(connectTimeout, readWriteTimeout time.Duration) *THttpRequest
SetTimeout sets connect time out and read-write time out for TRequest.
func (*THttpRequest) SetTransport ¶
func (b *THttpRequest) SetTransport(transport http.RoundTripper) *THttpRequest
SetTransport set the setting transport
func (*THttpRequest) SetUserAgent ¶
func (b *THttpRequest) SetUserAgent(useragent string) *THttpRequest
SetUserAgent sets User-Agent header field
func (*THttpRequest) Setting ¶
func (b *THttpRequest) Setting(setting THttpSettings) *THttpRequest
Setting Change request settings
func (*THttpRequest) StatusCode ¶
func (b *THttpRequest) StatusCode() (int, error)
返回状态码(可以真实的返回Http状态)
func (*THttpRequest) String ¶
func (b *THttpRequest) String() (string, error)
String returns the body string in response. it calls Response inner.
func (*THttpRequest) ToFile ¶
func (b *THttpRequest) ToFile(filename string) error
ToFile saves the body data in response to one file. it calls Response inner.
func (*THttpRequest) ToJSON ¶
func (b *THttpRequest) ToJSON(v interface{}) error
ToJSON returns the map that marshals from the body bytes as json in response . it calls Response inner.
func (*THttpRequest) ToXML ¶
func (b *THttpRequest) ToXML(v interface{}) error
ToXML returns the map that marshals from the body bytes as xml in response . it calls Response inner.
func (*THttpRequest) ToYAML ¶
func (b *THttpRequest) ToYAML(v interface{}) error
ToYAML returns the map that marshals from the body bytes as yaml in response . it calls Response inner.
func (*THttpRequest) XMLBody ¶
func (b *THttpRequest) XMLBody(obj interface{}) (*THttpRequest, error)
XMLBody adds request raw body encoding by XML.
func (*THttpRequest) YAMLBody ¶
func (b *THttpRequest) YAMLBody(obj interface{}) (*THttpRequest, error)
YAMLBody adds request raw body encoding by YAML.
type THttpSettings ¶
type THttpSettings struct { ShowDebug bool UserAgent string ConnectTimeout time.Duration ReadWriteTimeout time.Duration TLSClientConfig *tls.Config Proxy func(*http.Request) (*url.URL, error) Transport http.RoundTripper CheckRedirect func(req *http.Request, via []*http.Request) error EnableCookie bool Gzip bool DumpBody bool Retries int // if set to -1 means will retry forever RetryDelay time.Duration FilterChains []FilterChain }
THTTPSettings is the http.Client setting
type TIPData ¶
type TIPData struct { IP string `json:"ip"` Country string `json:"country"` Region string `json:"region"` City string `json:"city"` ISP string `json:"isp"` }
func GetPublicIPDetail ¶
"http://myexternalip.com/raw" 目前网址有问题,可以找其他网址
type TPingResult ¶
type TPingResult struct { Domain string IPAddr string DelayShort float64 DelayLong float64 DelayAverage float64 Lost int }
func Pinger ¶
func Pinger(host_name string, count int, size int, timeout time.Duration) (bool, *TPingResult, error)
输入:次数,发送包大小,网络超时 返回:是否OK,延时,是否稳定(ping超时),错误
func (*TPingResult) String ¶
func (Self *TPingResult) String() string