Documentation ¶
Index ¶
- Constants
- func AppendParamToUrl(url, param string) string
- func Base64Decode(str string) (string, error)
- func Base64DecodeV2(b []byte) ([]byte, error)
- func Base64Encode(str string) string
- func Base64EncodeV2(b []byte) []byte
- func HttpGet(urlStr string) (string, error)
- func HttpPost(urlStr string, param string) (string, error)
- func HttpPostForm(urlStr string, param url.Values) (string, error)
- func HttpPostJson(urlStr string, param string) (string, error)
- func HttpPostXml(urlStr string, xmlStr string) (string, error)
- func IsBlank(str string) bool
- func ParamValueToString(i interface{}) string
- func ParseUrlAndAppendParam(reqUrl string, queryParams map[string][]string) (string, error)
- func ReadBodyContent(httpResp *http.Response) (string, error)
- func ReadBodyContent2Byte(httpResp *http.Response) ([]byte, error)
- func TrimPath(path string, pos int) string
- func UnMarshalResponse(httpResp *http.Response, resp interface{}) error
- func UrlDecode(str string) (string, error)
- func UrlEncode(str string) string
- type HttpRequest
- func (this *HttpRequest) AddHeader(header, val string) *HttpRequest
- func (this *HttpRequest) Delete() (*HttpResponse, error)
- func (this *HttpRequest) Get() (*HttpResponse, error)
- func (this *HttpRequest) GetCookies() map[string]string
- func (this HttpRequest) GetHeaders() map[string]string
- func (this HttpRequest) GetMethod() string
- func (this HttpRequest) GetPostData() map[string]interface{}
- func (this HttpRequest) GetQueries() map[string]string
- func (this HttpRequest) GetRawPostData() string
- func (this *HttpRequest) GetTimeout() time.Duration
- func (this HttpRequest) GetUrl() string
- func (this *HttpRequest) Patch() (*HttpResponse, error)
- func (this *HttpRequest) Post() (*HttpResponse, error)
- func (this *HttpRequest) Put() (*HttpResponse, error)
- func (this *HttpRequest) Request() (*HttpResponse, error)
- func (this *HttpRequest) SetCookies(cookies map[string]string) *HttpRequest
- func (this *HttpRequest) SetDialTimeOut(TimeOutSecond int64) *HttpRequest
- func (this *HttpRequest) SetHeaders(headers map[string]string) *HttpRequest
- func (this *HttpRequest) SetMethod(method string) *HttpRequest
- func (this *HttpRequest) SetPostData(postData map[string]interface{}) *HttpRequest
- func (this *HttpRequest) SetPostType(typeStr string) *HttpRequest
- func (this *HttpRequest) SetQueries(queries map[string]string) *HttpRequest
- func (this *HttpRequest) SetRawPostData(rawPostData string) *HttpRequest
- func (this *HttpRequest) SetResponseTimeOut(TimeOutSecond int64) *HttpRequest
- func (this *HttpRequest) SetTimeout(TimeOutSecond int64) *HttpRequest
- func (this *HttpRequest) SetUrl(url string) *HttpRequest
- type HttpResponse
- type Params
Constants ¶
View Source
const ( CONTENT_TYPE_JSON = "application/json" CONTENT_TYPE_FORM = "application/x-www-form-urlencoded" CONTENT_TYPE_OCTET = "application/octet-stream" CONTENT_TYPE_MULTIPART = "multipart/form-data" CONTENT_TYPE_XML = "application/xml" CONTENT_TYPE_TEXTHTML = "text/html" CONTENT_TYPE_TEXTXML = "text/xml" )
Variables ¶
This section is empty.
Functions ¶
func Base64Decode ¶
func Base64DecodeV2 ¶ added in v1.0.4
func Base64Encode ¶
func Base64EncodeV2 ¶ added in v1.0.4
func HttpPostForm ¶
HttpPostForm param := url.Values{"参数名1": {"值1"}, "参数名2": {"值1","值N"}}
func ParamValueToString ¶
func ParamValueToString(i interface{}) string
func ParseUrlAndAppendParam ¶ added in v1.0.2
分析url并追加参数
func ReadBodyContent ¶ added in v1.0.2
func ReadBodyContent2Byte ¶ added in v1.0.2
func UnMarshalResponse ¶ added in v1.0.2
Types ¶
type HttpRequest ¶
type HttpRequest struct {
// contains filtered or unexported fields
}
请求结构体
func (*HttpRequest) AddHeader ¶
func (this *HttpRequest) AddHeader(header, val string) *HttpRequest
func (*HttpRequest) GetCookies ¶
func (this *HttpRequest) GetCookies() map[string]string
func (HttpRequest) GetHeaders ¶
func (this HttpRequest) GetHeaders() map[string]string
func (HttpRequest) GetMethod ¶
func (this HttpRequest) GetMethod() string
func (HttpRequest) GetPostData ¶
func (this HttpRequest) GetPostData() map[string]interface{}
func (HttpRequest) GetQueries ¶
func (this HttpRequest) GetQueries() map[string]string
func (HttpRequest) GetRawPostData ¶
func (this HttpRequest) GetRawPostData() string
func (*HttpRequest) GetTimeout ¶
func (this *HttpRequest) GetTimeout() time.Duration
func (HttpRequest) GetUrl ¶
func (this HttpRequest) GetUrl() string
func (*HttpRequest) Request ¶
func (this *HttpRequest) Request() (*HttpResponse, error)
func (*HttpRequest) SetCookies ¶
func (this *HttpRequest) SetCookies(cookies map[string]string) *HttpRequest
设置请求cookies
func (*HttpRequest) SetDialTimeOut ¶
func (this *HttpRequest) SetDialTimeOut(TimeOutSecond int64) *HttpRequest
func (*HttpRequest) SetHeaders ¶
func (this *HttpRequest) SetHeaders(headers map[string]string) *HttpRequest
设置请求头
func (*HttpRequest) SetMethod ¶
func (this *HttpRequest) SetMethod(method string) *HttpRequest
设置请求方法,返回Request结构体对象用于链式调用
func (*HttpRequest) SetPostData ¶
func (this *HttpRequest) SetPostData(postData map[string]interface{}) *HttpRequest
设置post请求的提交数据
func (*HttpRequest) SetPostType ¶
func (this *HttpRequest) SetPostType(typeStr string) *HttpRequest
func (*HttpRequest) SetQueries ¶
func (this *HttpRequest) SetQueries(queries map[string]string) *HttpRequest
设置url查询参数
func (*HttpRequest) SetRawPostData ¶
func (this *HttpRequest) SetRawPostData(rawPostData string) *HttpRequest
func (*HttpRequest) SetResponseTimeOut ¶
func (this *HttpRequest) SetResponseTimeOut(TimeOutSecond int64) *HttpRequest
func (*HttpRequest) SetTimeout ¶
func (this *HttpRequest) SetTimeout(TimeOutSecond int64) *HttpRequest
type HttpResponse ¶
type HttpResponse struct {
// contains filtered or unexported fields
}
func NewHttpResponse ¶
func NewHttpResponse() *HttpResponse
func (HttpResponse) GetHeaders ¶
func (this HttpResponse) GetHeaders() map[string]string
func (*HttpResponse) GetRaw ¶
func (this *HttpResponse) GetRaw() *http.Response
func (*HttpResponse) IsOk ¶
func (this *HttpResponse) IsOk() bool
func (*HttpResponse) SetRaw ¶
func (this *HttpResponse) SetRaw(r *http.Response) *HttpResponse
Click to show internal directories.
Click to hide internal directories.