httpsend

package
v0.0.0-...-1e877d2 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CONN_TIME_OUT = time.Second * 2
)
View Source
const (
	VERSION_INFO = "2.0"
)

By Bill Json-Rpc2.0 @filecoin Rpc

Variables

This section is empty.

Functions

func BuildData

func BuildData(params interface{}, method string) string

用于filecoin

func Get

func Get(apiURL string, params url.Values) (resData string, e error)

*

Get
@author Bill

func GetRandomChars

func GetRandomChars(num int) string

func GetRandomSring

func GetRandomSring(num int, str ...string) string

func OnGetJSON

func OnGetJSON(url, params string) string

OnGetJSON 发送get 请求

func OnPostForm

func OnPostForm(url string, data url.Values) (body []byte)

OnPostForm form 方式发送post请求

func OnPostJSON

func OnPostJSON(url, jsonstr string) []byte

OnPostJSON 发送修改密码

func Post

func Post(apiURL string, params url.Values) (resData string, err error)

* 网络请求POST

func SendGet

func SendGet(url, params string, obj interface{}) bool

SendGet 发送get 请求 返回对象

func SendGetEx

func SendGetEx(url string, reponse interface{}) bool

SendGetEx 发送GET请求

func SendGetWithTimeOut

func SendGetWithTimeOut(apiUrl string, params url.Values, time_out int) (resData string, e error)

* Get with TimeOut Code == 200 则返回,其他请打印错误 第三个参数设置超时 单位:秒 【0:则默认两秒】

func SendJsonReq

func SendJsonReq(uri string, data string, headers map[string]string) string

*

	@params url  请求地址
	@params msg  消息(json字符串)比如 `{"name":"Bill"}`
                         Ps:也可以使用  BuildData  方法构建数据
												@params params 泛型list参数   []interface{}{"123",123}
                                                @params method 调用方法       call

	@params header 携带的Http头   map[string]string{}{
						   "Content-Type" : "application/json",
                         }
	@return 返回字符串

func SendPost

func SendPost(requestBody interface{}, responseBody interface{}, url string) bool

SendPost 发送POST请求

func SendPostWithTimeOut

func SendPostWithTimeOut(apiUrl string, params url.Values, time_out int) (resData string, e error)

* Post with TimeOut Code == 200 则返回,其他请打印错误 第三个参数设置超时 单位:秒 【0:则默认两秒】

func SendRpc

func SendRpc(url string, msg []byte, headers map[string]string) (string, error)

func ToJsonString

func ToJsonString(data map[string]interface{}) string

func WriteJSON

func WriteJSON(w http.ResponseWriter, msg interface{})

WriteJSON 像指定client 发送json 包 msg message.MessageBody

Types

This section is empty.

Jump to

Keyboard shortcuts

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