utils

package
Version: v1.1.8 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2021 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FetchSource

func FetchSource(uri string) []byte

FetchSource 获取资源

func Get

func Get(path string, extends ...interface{}) ([]byte, error)

*

* @param path string,params param,app App,domain string
* @author struggler
* @description client get 注意:当传递App的时候会自动获取token 并添加到 param里
* @date 10:52 下午 2021/2/23
* @return []byte,error
*

func JsonToByte

func JsonToByte(t interface{}) []byte

func JsonToString

func JsonToString(t interface{}) string

func PostBody

func PostBody(path string, body []byte, extends ...interface{}) ([]byte, error)

*

* @param path string,params param,app App,domain string
* @author struggler
* @description client postJson 注意:当传递App的时候会自动获取token 并添加到 param里
* @date 10:52 下午 2021/2/23
* @return string,error
*

func PostBufferFile

func PostBufferFile(path, name string, file io.Reader, fileName string, extends ...interface{}) ([]byte, error)

*

* @param path,name string, file multipart.File,fileName *multipart.fileName,params param,app App,domain string
* @author struggler
* @description client postBufferFile 注意:当传递App的时候会自动获取token 并添加到 param里
* @date 10:52 下午 2021/2/23
* @return string,error
*

func PostBufferFileWithField

func PostBufferFileWithField(path, name string, file io.Reader, fileName string, fields map[string]string, extends ...interface{}) ([]byte, error)

func PostPathFile

func PostPathFile(path, name string, file io.Reader, filePath string, extends ...interface{}) ([]byte, error)

*

* @param path,name string, file io.Reader,filePath string,params param,app App,domain string
* @author struggler
* @description client postFilePath 注意:当传递App的时候会自动获取token 并添加到 param里
* @date 10:52 下午 2021/2/23
* @return string,error
*

func ReduceUrl

func ReduceUrl(uri string, params Query) (string, error)

ReduceUrl 合并url

Types

type App

type App interface {
	GetAccessToken(reflush ...bool) *Token
	GetConfig() Config
}

func ContextApp

func ContextApp(a App) App

ContextApp

type Config

type Config struct {
	Appid  string
	Secret string
}

type ContextToken added in v1.1.5

type ContextToken struct {
	Appid string
	Token string
}

func ExtractAppidAndAccessToken added in v1.1.5

func ExtractAppidAndAccessToken(appidAndAccessToken ...string) (ContextToken, error)

ExtractAppidAndAccessToken 提取appid 和 accessToken

type Domain

type Domain string

type Hook added in v1.1.3

type Hook func(appidAndAccessToken ...string) *Token

Hook [0] Appid [1] AccessToken

type MapBoolean

type MapBoolean map[string]bool

type MapInterface

type MapInterface map[string]interface{}

type MapStr

type MapStr map[string]string

type Query

type Query map[string]string

type Token

type Token struct {
	Token      string
	UpdateTime int
}

Jump to

Keyboard shortcuts

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