util

package
v0.0.0-...-20c3085 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2019 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var TimeOut time.Duration = 60 * time.Second

TimeOut 请求超时设置,默认1分钟

Functions

func AesDecrypt

func AesDecrypt(src, key []byte) (dst []byte, err error)

AesDecrypt AES-CBC解密,PKCS#7,传入密文和密钥,[]byte

func AesEncrypt

func AesEncrypt(src []byte, key []byte) ([]byte, error)

AesEncrypt AES-CBC加密+PKCS#7打包,传入明文和密钥

func GetBody

func GetBody(uri string) ([]byte, error)

GetBody 发送GET请求,返回body字节

func GetFile

func GetFile(filename, uri string) error

GetFile 下载文件

func GetJson

func GetJson(uri string, v interface{}) error

GetJson 发送GET请求解析json

func GetXml

func GetXml(uri string, v interface{}) error

GetXml 发送GET请求并解析xml

func PKCS7Pad

func PKCS7Pad(msg []byte, blockSize int) []byte

PKCS7Pad PKCS#7打包

func PKCS7UnPad

func PKCS7UnPad(msg []byte) []byte

PKCS7UnPad PKSC#7解包

func PostFile

func PostFile(fieldname, filename, uri string) ([]byte, error)

PostFile 上传文件

func PostJson

func PostJson(uri string, obj interface{}) ([]byte, error)

PostJson 发送Json格式的POST请求

func PostJsonPtr

func PostJsonPtr(uri string, obj interface{}, result interface{}, contentType ...string) (err error)

PostJsonPtr 发送Json格式的POST请求并解析结果到result指针

func PostMultipartForm

func PostMultipartForm(fields []MultipartFormField, uri string) (respBody []byte, err error)

PostMultipartForm 上传文件或其他表单数据

func PostXmlPtr

func PostXmlPtr(uri string, obj interface{}, result interface{}) (err error)

PostXmlPtr 发送Xml格式的POST请求并解析结果到result指针

func SetTimeOut

func SetTimeOut(d time.Duration)

Types

type MultipartFormField

type MultipartFormField struct {
	IsFile    bool
	Fieldname string
	Value     []byte
	Filename  string
}

MultipartFormField 文件或其他表单数据

Jump to

Keyboard shortcuts

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