ghttp

package
v1.30.36 Latest Latest
Warning

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

Go to latest
Published: May 16, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GET             = http.MethodGet
	POST            = http.MethodPost
	DELETE          = http.MethodDelete
	PUT             = http.MethodPut
	PATCH           = http.MethodPatch
	HEAD            = http.MethodHead
	OPTIONS         = http.MethodOptions
	ContentTypeJSON = "application/json"
	ContentTypeForm = "application/x-www-form-urlencoded"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Request

type Request struct {
	Client *http.Client
	// contains filtered or unexported fields
}

Request Http Request

func NewRequest

func NewRequest(method, urlString string) *Request

NewRequest 新的Request指针

func (*Request) AddCookie

func (m *Request) AddCookie(cookie *http.Cookie) *Request

AddCookie 添加COOKIE

func (*Request) AddFile

func (m *Request) AddFile(name, filename, path string) *Request

AddFile 增加文件

func (*Request) AddHeader

func (m *Request) AddHeader(key, value string) *Request

AddHeader 增加Header头

func (*Request) AddParam

func (m *Request) AddParam(key, value string) *Request

AddParam 增加Get请求参数

func (*Request) Exec

func (m *Request) Exec() *Response

Exec 发送HTTP请求

func (*Request) RemoveFile

func (m *Request) RemoveFile() *Request

RemoveFile 移除文件

func (*Request) SetBody

func (m *Request) SetBody(body io.Reader) *Request

SetBody 设定POST内容

func (*Request) SetContentType

func (m *Request) SetContentType(contentType string) *Request

SetContentType 设定Content-Type

func (*Request) SetHeader

func (m *Request) SetHeader(key, value string) *Request

SetHeader 设定Header头

func (*Request) SetHeaders

func (m *Request) SetHeaders(header http.Header) *Request

SetHeaders 设定Header头

func (*Request) SetParam

func (m *Request) SetParam(key, value string) *Request

SetParam 设定Get请求参数

func (*Request) SetParams

func (m *Request) SetParams(params cmap.CMap) *Request

SetParams 设定Get请求参数

func (*Request) SetStructParams

func (m *Request) SetStructParams(v interface{}) *Request

SetStructParams struct to Params

type Response

type Response struct {
	*http.Response
	// contains filtered or unexported fields
}

Response Http请求返回内容

func (*Response) Bytes

func (m *Response) Bytes() ([]byte, error)

Bytes 返回byte数据

func (*Response) Error

func (m *Response) Error() error

func (*Response) MustBytes

func (m *Response) MustBytes() []byte

MustBytes 返回byte数据

func (*Response) MustString

func (m *Response) MustString() string

MustString 返回string数据

func (*Response) String

func (m *Response) String() (string, error)

String 返回string数据

func (*Response) Unmarshal

func (m *Response) Unmarshal(v interface{}) error

Unmarshal 返回反序列化JSON

Jump to

Keyboard shortcuts

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