ghttp

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2022 License: MIT Imports: 6 Imported by: 1

README

ghttp

http requests and responses

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetUserAgent

func GetUserAgent() string

Types

type FormFile

type FormFile struct {
	FieldName string
	FileName  string
	Datas     io.Reader
}

type FormFiles

type FormFiles []FormFile

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * Http表单文件数据结构 * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

type HttpRequest

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

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * Http请求数据结构 * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

func (*HttpRequest) Delete

func (s *HttpRequest) Delete(url string) (IHttpResponse, error)

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * Delete请求 * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

func (*HttpRequest) Get

func (s *HttpRequest) Get(url string) (IHttpResponse, error)

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * Get请求 * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

func (*HttpRequest) Post

func (s *HttpRequest) Post(url string) (IHttpResponse, error)

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * Post请求 * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

func (*HttpRequest) Put

func (s *HttpRequest) Put(url string) (IHttpResponse, error)

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * Put请求 * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

func (*HttpRequest) SetCookies

func (s *HttpRequest) SetCookies(cookies map[string]string)

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * 设置Cookie * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

func (*HttpRequest) SetData

func (s *HttpRequest) SetData(data map[string]string)

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * 设置字典数据 * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

func (*HttpRequest) SetFiles

func (s *HttpRequest) SetFiles(files FormFiles)

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * 设置文件数据 * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

func (*HttpRequest) SetHeaders

func (s *HttpRequest) SetHeaders(headers map[string]string)

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * 设置头 * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

func (*HttpRequest) SetJson

func (s *HttpRequest) SetJson(json interface{})

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * 设置Json数据 * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

func (*HttpRequest) SetParams

func (s *HttpRequest) SetParams(params map[string]string)

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * 设置参数 * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

func (*HttpRequest) SetUserAgent

func (s *HttpRequest) SetUserAgent(userAgent string)

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * 设置用户代理http头 * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

type HttpResponse

type HttpResponse struct {
	Header     http.Header
	Data       []byte
	StatusCode int
	Status     string
}
 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
	 * Http响应数据结构
	 * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

func (*HttpResponse) GetData

func (s *HttpResponse) GetData() []byte

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * 获取请求内容 * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

func (*HttpResponse) GetHeader

func (s *HttpResponse) GetHeader() http.Header

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * 获取请求头 * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

func (*HttpResponse) GetStatus

func (s *HttpResponse) GetStatus() string

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * 获取状态描述 * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

func (*HttpResponse) GetStatusCode

func (s *HttpResponse) GetStatusCode() int

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * 获取状态码 * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

type IHttpRequest

type IHttpRequest interface {
	Get(url string) (IHttpResponse, error)
	Post(url string) (IHttpResponse, error)
	Put(url string) (IHttpResponse, error)
	Delete(url string) (IHttpResponse, error)

	SetUserAgent(userAgent string)
	SetHeaders(headers map[string]string)
	SetParams(params map[string]string)
	SetCookies(cookies map[string]string)
	SetJson(json interface{})
	SetData(data map[string]string)
	SetFiles(files FormFiles)
}
 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
	 * Http请求接口
	 * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

func NewHttpRequest

func NewHttpRequest() IHttpRequest

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * 初始化Http请求 * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

type IHttpResponse

type IHttpResponse interface {
	GetData() []byte
	GetHeader() http.Header
	GetStatusCode() int
	GetStatus() string
}
 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
	 * Http响应接口
	 * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Jump to

Keyboard shortcuts

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