httpclient

package
v1.8.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 7, 2024 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	BaseUrl string
	// contains filtered or unexported fields
}

func NewClient

func NewClient() *Client

func (*Client) Do

func (c *Client) Do(request *Request) (clientResp *Response, err error)

func (*Client) Get

func (c *Client) Get(request *Request) (clientResp *Response, err error)

RunGet 执行Get请求

func (*Client) Post

func (c *Client) Post(request *Request) (clientResp *Response, err error)

RunGet 执行Post请求

func (*Client) SplicingUrl added in v1.6.7

func (*Client) SplicingUrl(baseUrl string, url string) string

type Factory added in v1.6.7

type Factory struct {
	// contains filtered or unexported fields
}

func (*Factory) Create added in v1.6.7

func (cf *Factory) Create(baseUrl string) (*Client, error)

type IDiscoveryClientFactory added in v1.6.7

type IDiscoveryClientFactory interface {
	Create(baseUrl string) (*Client, error)
}

func NewDiscoveryClientFactory added in v1.6.7

func NewDiscoveryClientFactory(selector servicediscovery.ISelector) IDiscoveryClientFactory

type IFactory added in v1.6.7

type IFactory interface {
	Create(baseUrl string) (*Client, error)
}

func NewFactory added in v1.6.7

func NewFactory() IFactory

type Request

type Request struct {
	// contains filtered or unexported fields
}

func WithFormRequest added in v1.6.7

func WithFormRequest(params map[string]interface{}) *Request

WithFormRequest 快速配置表单请求类型

func WithJsonRequest added in v1.6.7

func WithJsonRequest(json string) *Request

WithFormRequest 快速配置表单请求类型

func WithRequest added in v1.6.7

func WithRequest() *Request

func (*Request) AddFile

func (c *Request) AddFile(name string, filePath string) *Request

WithFile 添加文件form-data方式发送

func (*Request) ClearParam

func (c *Request) ClearParam() *Request

ClearParam 清空重置请求参数

func (*Request) ContentType

func (c *Request) ContentType(value string) *Request

func (*Request) DisableKeepAlives

func (c *Request) DisableKeepAlives() *Request

DisableKeepAlives 关闭KeepAlives

func (*Request) Error

func (c *Request) Error() error

func (*Request) FormParams

func (c *Request) FormParams(obj map[string]interface{}) *Request

参数设置 表单请求支持json和form两种类型

func (*Request) GET

func (c *Request) GET(url string) *Request

func (*Request) GetUrl added in v1.6.7

func (c *Request) GetUrl() string

func (*Request) Header

func (c *Request) Header(key, value string) *Request

Header 设置header头信息

func (*Request) POST

func (c *Request) POST(url string) *Request

func (*Request) SetTimeout

func (c *Request) SetTimeout(timeout int) *Request

func (*Request) SkipHttps

func (c *Request) SkipHttps() *Request

SkipHttps 跳过https证书校验

func (*Request) WithBody

func (c *Request) WithBody(bodyStream string) *Request

直接传递body中的参数

func (*Request) WithContentTypeAsJson added in v1.8.6

func (c *Request) WithContentTypeAsJson() *Request

func (*Request) WithCookie

func (c *Request) WithCookie() *Request

cookie保持 通过配置请求id将cookie保持

func (*Request) WithHost

func (c *Request) WithHost(host string) *Request

WithHost 添加请求头host

type Response

type Response struct {
	Body        []byte // response body
	BodyRaw     *http.Response
	RequestTime time.Duration
	CookieData  map[string]*http.Cookie
}

func (*Response) GetRequestTime

func (c *Response) GetRequestTime() time.Duration

func (*Response) String

func (c *Response) String() string

type UploadFile

type UploadFile struct {
	// 表单名称
	Name string
	// 文件路径
	Filepath string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL