Documentation
¶
Index ¶
- Constants
- Variables
- func NewDefaultRestGo(cli *http.Client, trace *httptrace.ClientTrace) *defaultRestGo
- type AnyFunc
- type Builder
- func (builder *Builder) BaseUrl(baseURL string) *Builder
- func (builder *Builder) BodyPayload(body []byte) *Builder
- func (builder *Builder) ContentType(contentType ContentType) *Builder
- func (builder *Builder) CtxSend(ctx context.Context, method HttpMethod, url string) (Response, error)
- func (builder *Builder) CtxSendWithRetry(ctx context.Context, method HttpMethod, url string, ...) (Response, error)
- func (builder *Builder) Curl(curlConsumer func(curl string)) *Builder
- func (builder *Builder) CustomRestGo(customRestGo RestGo) *Builder
- func (builder *Builder) File(key, path string) *Builder
- func (builder *Builder) FileReader(key, filename string, reader io.Reader) *Builder
- func (builder *Builder) HeaderFunc(hf SFunc) *Builder
- func (builder *Builder) Headers(headers map[string]string, conditionFuncs ...ConditionFunc) *Builder
- func (builder *Builder) PathVariable(pathVal map[string]string) *Builder
- func (builder *Builder) Payload(body interface{}) *Builder
- func (builder *Builder) PayloadFunc(pf AnyFunc) *Builder
- func (builder *Builder) Query(queryVal map[string]string) *Builder
- func (builder *Builder) RspUnmarshal(v interface{}) *Builder
- func (builder *Builder) Send(method HttpMethod, url string) (Response, error)
- func (builder *Builder) SendWithRetry(method HttpMethod, url string, resF func(respW Response, err error) error, ...) (Response, error)
- type ConditionFunc
- type ContentType
- type HttpMethod
- type IResponse
- func (wrapper *IResponse) Body() []byte
- func (wrapper *IResponse) BodyStr() string
- func (wrapper *IResponse) BodyUnmarshal(v interface{}) error
- func (wrapper *IResponse) Header(key string) string
- func (wrapper *IResponse) Proto() string
- func (wrapper *IResponse) ProtoMajor() int
- func (wrapper *IResponse) ProtoMinor() int
- func (wrapper *IResponse) Status() string
- func (wrapper *IResponse) StatusCode() int
- type Map
- type Response
- type RestGo
- type SFunc
- type SMap
Constants ¶
View Source
const ( GET = HttpMethod("GET") POST = HttpMethod("POST") PUT = HttpMethod("PUT") DELETE = HttpMethod("DELETE") ApplicationJson = ContentType("application/json") FormData = ContentType("multipart/form-data") FormDataEncoded = ContentType("application/x-www-form-urlencoded") OctetStream = ContentType("binary/octet-stream") )
Variables ¶
View Source
var ConsolePrint = func(curl string) { fmt.Println(curl) }
Functions ¶
func NewDefaultRestGo ¶ added in v1.0.1
func NewDefaultRestGo(cli *http.Client, trace *httptrace.ClientTrace) *defaultRestGo
Types ¶
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
func NewRestGoBuilder ¶
func NewRestGoBuilder() *Builder
func (*Builder) BodyPayload ¶
BodyPayload 不做任何格式化,直接作为body传递
func (*Builder) ContentType ¶
func (builder *Builder) ContentType(contentType ContentType) *Builder
func (*Builder) CtxSendWithRetry ¶
func (*Builder) CustomRestGo ¶
func (*Builder) FileReader ¶
FileReader 另外一种上传文件的方式,手动指定reader,如果同时设置调用了 File 方法,那么 File 方法中的参数会优先
func (*Builder) HeaderFunc ¶
HeaderFunc 通过函数计算需要传递的header选项
func (*Builder) Headers ¶
func (builder *Builder) Headers(headers map[string]string, conditionFuncs ...ConditionFunc) *Builder
func (*Builder) PathVariable ¶
PathVariable 路径参数
func (*Builder) PayloadFunc ¶
PayloadFunc 通过函数计算需要传递的payload
func (*Builder) RspUnmarshal ¶
RspUnmarshal 对响应体进行反序列化,响应体为JSON形式 如果只关心响应体序列化到结构体的结果,通过设置这个可以减少代码的编写量
func (*Builder) Send ¶
func (builder *Builder) Send(method HttpMethod, url string) (Response, error)
func (*Builder) SendWithRetry ¶
type ConditionFunc ¶
type ContentType ¶
type ContentType string
type HttpMethod ¶
type HttpMethod string
type IResponse ¶
type IResponse struct {
// contains filtered or unexported fields
}
func (*IResponse) BodyUnmarshal ¶
func (*IResponse) ProtoMajor ¶
func (*IResponse) ProtoMinor ¶
func (*IResponse) StatusCode ¶
Click to show internal directories.
Click to hide internal directories.