request

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

* @Author: nijineko * @Date: 2024-08-29 19:53:53 * @LastEditTime: 2024-09-01 05:16:05 * @LastEditors: nijineko * @Description: 请求体处理 * @FilePath: \yuzuhttp\request\body.go

* @Author: nijineko * @Date: 2024-09-01 04:22:54 * @LastEditTime: 2024-09-01 04:22:59 * @LastEditors: nijineko * @Description: cookie处理 * @FilePath: \yuzuhttp\request\cookie.go

* @Author: nijineko * @Date: 2024-08-29 19:48:25 * @LastEditTime: 2024-08-29 20:02:31 * @LastEditors: nijineko * @Description: 请求头处理 * @FilePath: \yuzuhttp\request\header.go

* @Author: nijineko * @Date: 2024-08-29 19:40:54 * @LastEditTime: 2024-08-30 17:25:10 * @LastEditors: nijineko * @Description: 请求处理 * @FilePath: \yuzuhttp\request\request.go

* @Author: nijineko * @Date: 2024-08-29 20:18:41 * @LastEditTime: 2024-08-29 20:20:53 * @LastEditors: nijineko * @Description: 参数设置 * @FilePath: \yuzuhttp\request\setting.go

* @Author: nijineko * @Date: 2024-08-29 19:54:36 * @LastEditTime: 2024-09-02 02:27:39 * @LastEditors: nijineko * @Description: URL参数处理 * @FilePath: \yuzuhttp\request\urlValue.go

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Request

type Request struct {
	Method   string            // 请求方法
	URL      string            // 请求地址
	URLValue map[string]string // GET参数
	Header   map[string]string // 请求头
	Cookie   map[string]string // Cookie
	Body     io.ReadCloser     // 请求体

	Error error // 错误
	// contains filtered or unexported fields
}

请求对象

func New

func New(method, url string) *Request

*

  • @description: 初始化请求
  • @param {string} method 请求方法
  • @param {string} url 请求地址
  • @return {*Request} 请求对象

func (*Request) AddCookie added in v0.2.0

func (r *Request) AddCookie(Key, Value string) *Request

*

  • @description: 添加Cookie
  • @param {string} Key Key
  • @param {string} Value Value
  • @return {*Request} 请求对象

func (*Request) AddHeader

func (r *Request) AddHeader(Key, Value string) *Request

*

  • @description: 添加请求头
  • @param {string} Key Key
  • @param {string} Value Value

func (*Request) AddQuery added in v0.2.1

func (r *Request) AddQuery(key, value string) *Request

*

  • @description: 添加URL参数
  • @param {string} Key Key
  • @param {string} Value Value
  • @return {*Request} 请求对象

func (*Request) AddURLValue

func (r *Request) AddURLValue(Key, Value string) *Request

*

  • @description: 添加URL参数
  • @param {string} Key Key
  • @param {string} Value Value
  • @return {*Request} 请求对象

func (*Request) Do

func (r *Request) Do() *response.Response

*

  • @description: 发起请求
  • @return {*response.Response} 响应对象

func (*Request) GetCookie added in v0.2.0

func (r *Request) GetCookie(Key string) string

*

  • @description: 获取Cookie
  • @param {string} Key Key
  • @return {string} Value

func (*Request) GetHeader

func (r *Request) GetHeader(Key string) string

*

  • @description: 获取请求头
  • @param {string} Key Key
  • @return {string} Value

func (*Request) GetURLValue

func (r *Request) GetURLValue(Key string) string

*

  • @description: 获取URL参数
  • @param {string} Key Key
  • @return {string} Value

func (*Request) RemoveCookie added in v0.2.0

func (r *Request) RemoveCookie(Key string) *Request

*

  • @description: 移除Cookie
  • @param {string} Key Key
  • @return {*Request} 请求对象

func (*Request) RemoveHeader

func (r *Request) RemoveHeader(Key string) *Request

*

  • @description: 移除请求头
  • @param {string} key Key
  • @return {*Request} 请求对象

func (*Request) RemoveURLValue

func (r *Request) RemoveURLValue(Key string) *Request

*

  • @description: 移除URL参数
  • @param {string} Key Key
  • @return {*Request} 请求对象

func (*Request) SetBody

func (r *Request) SetBody(Body io.ReadCloser) *Request

*

  • @description: 设置请求体
  • @param {io.ReadCloser} Body 请求体
  • @return {*Request} 请求对象

func (*Request) SetBodyBytes

func (r *Request) SetBodyBytes(Body []byte) *Request

*

  • @description: 设置Bytes请求体
  • @param {[]byte} Body 请求体
  • @return {*Request} 请求对象

func (*Request) SetBodyFormData

func (r *Request) SetBodyFormData(FormData *multipartForm.Form) *Request

*

  • @description: 设置FormData格式请求体
  • @param {map[string]string} FormData 表单数据
  • @return {*Request} 请求对象

func (*Request) SetBodyFormUrlencoded

func (r *Request) SetBodyFormUrlencoded(FormData map[string]string) *Request

*

  • @description: 设置FormUrlencoded格式请求体
  • @param {map[string]string} FormData 表单数据
  • @return {*Request} 请求对象

func (*Request) SetBodyJSON added in v0.2.0

func (r *Request) SetBodyJSON(JsonData any) *Request

*

  • @description: 设置Json格式请求体
  • @param {any} JsonData Json数据
  • @return {*Request} 请求对象

func (*Request) SetBodyString

func (r *Request) SetBodyString(Body string) *Request

*

  • @description: 设置String请求体
  • @param {string} Body 请求体
  • @return {*Request} 请求对象

func (*Request) SetBodyXML added in v0.2.0

func (r *Request) SetBodyXML(XMLData any) *Request

*

  • @description: 设置XML格式请求体
  • @param {any} XMLData XML数据
  • @return {*Request} 请求对象

func (*Request) SetCookies added in v0.2.0

func (r *Request) SetCookies(Cookies map[string]string) *Request

*

  • @description: 设置Cookie
  • @param {map[string]string} Cookies Cookie
  • @return {*Request} 请求对象

func (*Request) SetEnableHTTPProxy

func (r *Request) SetEnableHTTPProxy(Enable bool) *Request

*

  • @description: 设置是否启用HTTP代理环境变量支持
  • @param {bool} enable
  • @return {*Request}

func (*Request) SetEnableNon200Error

func (r *Request) SetEnableNon200Error(Enable bool) *Request

*

  • @description: 设置是否启用非200状态码时返回错误
  • @param {bool} enable
  • @return {*Request}

func (*Request) SetHeaders

func (r *Request) SetHeaders(Headers map[string]string) *Request

*

  • @description: 设置请求头
  • @param {map[string]string} Headers 请求头

func (*Request) SetQuerys added in v0.2.1

func (r *Request) SetQuerys(Params map[string]string) *Request

*

  • @description: 设置URL参数
  • @param {map[string]string} Params URL参数
  • @return {*Request} 请求对象

func (*Request) SetURLValues

func (r *Request) SetURLValues(Params map[string]string) *Request

*

  • @description: 设置URL参数
  • @param {map[string]string} Params URL参数
  • @return {*Request} 请求对象

Directories

Path Synopsis
* @Author: nijineko * @Date: 2024-08-30 16:37:03 * @LastEditTime: 2024-08-30 17:09:25 * @LastEditors: nijineko * @Description: 表单处理封装 * @FilePath: \yuzuhttp\request\multipartForm\multipartForm.go
* @Author: nijineko * @Date: 2024-08-30 16:37:03 * @LastEditTime: 2024-08-30 17:09:25 * @LastEditors: nijineko * @Description: 表单处理封装 * @FilePath: \yuzuhttp\request\multipartForm\multipartForm.go

Jump to

Keyboard shortcuts

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