ghttp

package
v1.2.3 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2023 License: MIT Imports: 8 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"
	ContentTypeFormUrl  = "application/x-www-form-urlencoded"
	ContentTypeFormData = "multipart/form-data"
)

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 new request

func (*Request) AddCookie

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

func (*Request) AddHeader

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

func (*Request) Exec

func (m *Request) Exec() *Response

func (*Request) RemoveFile

func (m *Request) RemoveFile() *Request

func (*Request) SetBody

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

func (*Request) SetContentType

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

func (*Request) SetFile added in v1.2.1

func (m *Request) SetFile(field, fileName, path string) (err error)

func (*Request) SetForm added in v1.2.1

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

func (*Request) SetForms added in v1.2.1

func (m *Request) SetForms(v any) *Request

SetForms struct to Params

func (*Request) SetHeader

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

func (*Request) SetHeaders

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

func (*Request) SetJsonBody added in v1.2.1

func (m *Request) SetJsonBody(v any) *Request

func (*Request) SetUrlValue added in v1.2.1

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

func (*Request) SetUrlValues added in v1.2.1

func (m *Request) SetUrlValues(v any) *Request

SetUrlValues 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)

func (*Response) Error

func (m *Response) Error() error

func (*Response) MustBytes

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

func (*Response) MustString

func (m *Response) MustString() string

func (*Response) String

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

func (*Response) Unmarshal

func (m *Response) Unmarshal(v any) error

Jump to

Keyboard shortcuts

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