Documentation ¶
Index ¶
- Constants
- Variables
- func HttpGet(httpClient *httpClient, httpUrl string, data interface{}, ...) (*HttpResponse, *HttpError)
- func HttpGetWithCtx(ctx context.Context, httpClient *httpClient, httpUrl string, data interface{}, ...) (*HttpResponse, *HttpError)
- func HttpPost(httpClient *httpClient, httpUrl string, data interface{}, ...) (*HttpResponse, *HttpError)
- func HttpPostJson(httpUrl string, data []byte, timeOut int) (*HttpResponse, *HttpError)
- func HttpPostWithCtx(ctx context.Context, httpClient *httpClient, httpUrl string, data interface{}, ...) (*HttpResponse, *HttpError)
- func NewHttpClient() *httpClient
- func NewHttpClientNodeId(nodeId int64) *httpClient
- func NewHttpClientNodeIdWithCtx(ctx context.Context, nodeId int64) *httpClient
- func NewHttpClientTimeOut(timeOut int, nodeId int64) *httpClient
- func NewHttpClientTimeOutCtx(ctx context.Context, timeOut int, nodeId int64) *httpClient
- func NewHttpClientWithCtx(ctx context.Context) *httpClient
- type FnError
- type FnSuccess
- type HttpError
- type HttpResponse
- type TimeOutType
- type Worker
Constants ¶
View Source
const ( HTTP_ERROR_TIME_OUT = 122 //超时 HTTP_SUCCESS = 200 //正常 HTTP_ERROR = 101 //错误 HTTP_TIME_OUT = 5 //默认超时时间(秒) HTTP_MAX_TRY_TIME = 5 //默认最大重试次数 TIME_OUT_TYPE_SECOND TimeOutType = 11 TIME_OUT_TYPE_MILLISECOND TimeOutType = 12 )
Variables ¶
View Source
var (
DEFAULT_NODE_ID int64 = 1
)
Functions ¶
func HttpGet ¶
func HttpGet(httpClient *httpClient, httpUrl string, data interface{}, header map[string]string, cookie []*http.Cookie, timeOut int) (*HttpResponse, *HttpError)
* 发送get请求 * @param httpUrl string 请求地址 * @param header map[string]string 请求头 * @param timeOut 超时时间(秒)
func HttpGetWithCtx ¶ added in v1.0.17
func HttpPost ¶
func HttpPost(httpClient *httpClient, httpUrl string, data interface{}, header map[string]string, cookie []*http.Cookie, timeOut int) (*HttpResponse, *HttpError)
* 发送post请求 * @param httpUrl string 请求地址 * @param data interface 发送数据 * @param header map[string]string 请求头 * @param timeOut 超时时间(秒)
func HttpPostJson ¶
func HttpPostJson(httpUrl string, data []byte, timeOut int) (*HttpResponse, *HttpError)
* 发送post json
func HttpPostWithCtx ¶ added in v1.0.17
func NewHttpClientNodeId ¶
func NewHttpClientNodeId(nodeId int64) *httpClient
func NewHttpClientNodeIdWithCtx ¶ added in v1.0.17
func NewHttpClientTimeOut ¶
func NewHttpClientTimeOutCtx ¶ added in v1.0.17
func NewHttpClientWithCtx ¶ added in v1.0.17
Types ¶
type FnSuccess ¶
type FnSuccess func(string, *HttpResponse)
type HttpResponse ¶
type HttpResponse struct { Resp *http.Response StatusCode int //请求状态 Content string //内容 ContentBytes []byte //内容数组 Cookie []*http.Cookie Header http.Header TryTime int }
* 客户端访问请求 @param url string 发送地址 @param data interface{} 发送数据 @param contentType string 数据类型 @param timeout int 超时时间(秒)
type TimeOutType ¶
type TimeOutType int
Click to show internal directories.
Click to hide internal directories.