Documentation ¶
Index ¶
- Constants
- type HttpError
- type Request
- func (r *Request) AddUrl(url string)
- func (r *Request) SetBody(body interface{})
- func (r *Request) SetHeader(name string, value string)
- func (r *Request) SetIsAll(b bool)
- func (r *Request) SetIsConcurrency(b bool)
- func (r *Request) SetMethod(method string)
- func (r *Request) SetQueryParams(name string, value string)
- func (r *Request) SetRetryCount(tryCount int)
- func (r *Request) SetRetryWaitTime(waitTime time.Duration)
- func (r *Request) SetTimeout(timeout time.Duration)
- type Response
- func HttpBadRequest(msg string) *Response
- func HttpFail(msg string) *Response
- func HttpFailForCode(code int64, msg string) *Response
- func HttpForbidden(msg string) *Response
- func HttpNotFound(msg string) *Response
- func HttpServerError(msg string) *Response
- func HttpSuccess(data interface{}) *Response
- func HttpSuccessByCode(code int64, data interface{}) *Response
- func HttpUnauthorized(msg string) *Response
Constants ¶
View Source
const ( TAG = "gohttpx" CONTENT_TYPE_XML = "application/xml" CONTENT_TYPE_JSON = "application/json" CONTENT_TYPE_FORM = "application/x-www-form-urlencoded" )
View Source
const ( POST = "post" GET = "get" )
View Source
const ( HttpUnknownError = 1000 HttpRetryError = 2000 HttpParamsError = 3000 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HttpError ¶ added in v1.1.11
func HttpConcurrencyRequest ¶ added in v1.1.12
带多个Urls重试逻辑,并发请求,速度快先到达后 直接返回,其他请求取消
func HttpPostJson ¶
func HttpRequest ¶ added in v1.1.11
带多个Urls重试逻辑
type Request ¶ added in v1.1.11
type Request struct { Url string Urls []string // 如果有值,当url 请求失败时继续用这里的接口尝试,直到成功返回或者全部失败 Method string Body interface{} //post body 参数 QueryParams map[string]string //get 参数 Headers map[string]string Timeout time.Duration RetryCount int RetryWaitTime time.Duration IsAll bool //一次性并发,默认false, IsConcurrency=true时生效,isAll=true时,一开始url+urls 并行请求,否则先请求url,再并行请求urls IsConcurrency bool //并行处理,默认false,url--> urls 一个一个串行请求 //trace infos TraceInfo resty.TraceInfo ResponseTime time.Duration ResponseProto string Response *resty.Response }
func (*Request) SetIsConcurrency ¶ added in v1.1.12
func (*Request) SetQueryParams ¶ added in v1.1.12
func (*Request) SetRetryCount ¶ added in v1.1.12
func (*Request) SetRetryWaitTime ¶ added in v1.1.12
func (*Request) SetTimeout ¶ added in v1.1.12
type Response ¶ added in v1.1.11
type Response struct { Code int64 `json:"code"` Msg string `json:"msg"` Data interface{} `json:"data,omitempty"` }
func HttpBadRequest ¶ added in v1.1.11
请求格式错误,比如参数格式、参数字段名等 不正确
func HttpFailForCode ¶ added in v1.1.11
如需返回特殊错误码,调用此接口
func HttpSuccessByCode ¶ added in v1.1.11
func HttpUnauthorized ¶ added in v1.1.11
用户没有访问权限,需要进行身份认证
Click to show internal directories.
Click to hide internal directories.