rghttp

package
v1.0.18 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2023 License: MIT Imports: 14 Imported by: 0

README

HTTP工具

使用

// 地址
url := "http:xxxx"
// 参数
param := `{"id": 1}`
// 实例化一个请求对象
httpClient := rghttp.Client {
    Param : param,
    Method: "POST", // 请求方式
    Header: map[string]string{ // header头
        "Content-Type": "application/json",
        },
    Url: url,
    This: this // 上下文对象this
    }

httpCode, data, err := httpClient.GetApi()
if err != nil {
  // 请求错误了
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Param   interface{}
	Method  string
	Header  map[string]string
	Url     string
	Timeout int               // 超时时间,如果没天默认10秒
	This    *rgrequest.Client `json:"-"` // json解析忽略
	// contains filtered or unexported fields
}

func (*Client) GetApi

func (i *Client) GetApi() (data string, err error)

func (*Client) Proxy added in v1.0.15

func (i *Client) Proxy(scheme, host, path string)

Proxy 转发 @Param : scheme: "http" host:"127.0.0.1" path:"/api/get" @Return : nil @Author : LiJunDong @Time : 2023-02-09

Jump to

Keyboard shortcuts

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