httpclient

package
v0.0.0-...-4dc1fac Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DEF_CONTENT_TYPE = "application/json; charset=utf-8"

	HEADER_NAME_CONTENT_TYPE = "Content-Type"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type HttpClient

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

http 简单封装

func NewHttpClient

func NewHttpClient() *HttpClient

func (*HttpClient) Do

func (hc *HttpClient) Do(method string, url string, request interface{}, response interface{}, opt ...Option) (err error)

url 不能带query参数,(不能包含 ? & 之类的) purlObj, _ := url.Parse(murl) 后续考虑使用url先解析再处理 requset 为 http请求中 body response 为 http 响应

type Option

type Option func(*Options)

func WithContentType

func WithContentType(value string) Option

Content

func WithHeader

func WithHeader(key, value string) Option

Header 字段

func WithHeaders

func WithHeaders(param map[string]string) Option

Header 字段

func WithOptionParams

func WithOptionParams(param map[string]string) Option

func WithUrlParam

func WithUrlParam(key, value string) Option

Url 参数

func WithUrlParams

func WithUrlParams(param map[string]string) Option

Url 参数

type Options

type Options struct {
	UrlParams map[string]string //Url 中的参数 http://xxxxxx/  ? k=1&
	Headers   map[string]string //Header

	Params map[string]string // 其他参数

}

Jump to

Keyboard shortcuts

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