myhttp

package
v0.0.0-...-faf29f7 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: MIT Imports: 16 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetHeader

func GetHeader(url string, header http.Header) ([]byte, error)

GetHeader get by head

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, error)

OnPostJSON 发送修改密码

func PostFile

func PostFile(filename, fieldname, targetURL string) (result string, e error)

PostFile 模拟客戶端文件上传 fieldname 注意与服务器端保持一致

func PostHeader

func PostHeader(url, jsonstr string, header http.Header) ([]byte, error)

PostHeader post by head

func SendGet

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

SendGet 发送get 请求 返回对象

func SendGetEx

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

SendGetEx 发送GET请求

func SendPost

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

SendPost 发送POST请求

func UploadMoreFile

func UploadMoreFile(r *http.Request, dir string) (result bool, optionDirs []string)

UploadMoreFile 多文件上传,dir:空则使用文件后缀做dir

func WriteJSON

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

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

Types

type MyHttpClient

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

func NewMyHttpClient

func NewMyHttpClient() *MyHttpClient

NewHttpClient 创建http client实例

func (*MyHttpClient) GetClient

func (c *MyHttpClient) GetClient() *http.Client

func (*MyHttpClient) SendGet

func (c *MyHttpClient) SendGet(url string, params string, responseBody interface{}) error

SendPost 发送POST请求

func (*MyHttpClient) SendPost

func (c *MyHttpClient) SendPost(url string, params string, responseBody interface{}) error

SendPost 发送POST请求

Jump to

Keyboard shortcuts

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