util

package
v0.11.1 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2022 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EnterPassword  = "Enter Password"
	RepeatPassword = "Repeat Password"
)

Variables

View Source
var (
	ErrPasswordInconsistent = errors.New("passwords are inconsistent")
)
View Source
var (
	ErrSignInFailed = errors.New("sign in failed")
)

Functions

func ConfirmPassword added in v0.7.0

func ConfirmPassword() (string, error)

func ConvertStringToMap added in v0.7.0

func ConvertStringToMap(key string) map[string]string

ConvertStringToMap 将 'key1=value1;key2=value2' 转换成 map

func Decrypt

func Decrypt(key, ciphertext []byte) []byte

func Encrypt

func Encrypt(key, text []byte) (d []byte)

func GetJson added in v0.6.0

func GetJson(url string, header map[string]string, rsp interface{}) error

func GetPassword added in v0.5.1

func GetPassword() (string, error)

func NewJar added in v0.7.0

func NewJar(key, domain, u string) *cookiejar.Jar

NewJar 从给定 cookie 字符串构造 jar

func NewRequest added in v0.7.0

func NewRequest(method, url string, body io.Reader) (*http.Request, context.CancelFunc, error)

func NewTLSConfig added in v0.7.0

func NewTLSConfig(ca, cert, key string) *tls.Config

func ParseBody added in v0.7.0

func ParseBody(client *http.Client, u string, v interface{}) error

ParseBody 解析 body 中的 json 数据到 v

func ParseBodyHeader added in v0.7.0

func ParseBodyHeader(client *http.Client, u string, header map[string]string) error

ParseBodyHeader 用于访问一个 url, 并且可以指定 http.Request header

func ParseBodyPost added in v0.7.0

func ParseBodyPost(client *http.Client, u string, reader io.Reader, v interface{}) error

ParseBodyPost 可以指定 http.Request body

func ParseRawBody added in v0.7.0

func ParseRawBody(client *http.Client, u string) ([]byte, error)

ParseRawBody 读取 body 为 []byte

func PopulateStruct added in v0.7.0

func PopulateStruct(key string, s interface{}) error

PopulateStruct 从 key 中解码数据到 s

func PostForm added in v0.7.0

func PostForm(url string, f url.Values) (*http.Client, *http.Response, error)

PostForm 使用带 context 方式发送请求, 并返回 client 和 response. 返回 client 的意图是其中保存了 cookie, 以便后续发送请求可重用该 cookie.

func ReadPassword added in v0.5.1

func ReadPassword(prompt string) (string, error)

func ResolveCookies added in v0.7.0

func ResolveCookies(raw, domain string) []*http.Cookie

ResolveCookies 从字符构造 http.Cookie

func Salt

func Salt() string

func SendJson added in v0.10.0

func SendJson(u string, req, rsp interface{}, options ...SendJsonOption) error

func VerifyDate added in v0.7.0

func VerifyDate(raw string) error

VerifyDate 验证指定时间字符串与当前时间的日期是否相同

func WithSalt

func WithSalt(pass, salt string) string

Types

type SendJsonOption added in v0.10.0

type SendJsonOption func(sjo *sendJsonOption)

func WithBearer added in v0.10.0

func WithBearer(t string) SendJsonOption

func WithDebug added in v0.10.0

func WithDebug(d bool) SendJsonOption

func WithHeader added in v0.10.0

func WithHeader(h map[string]string) SendJsonOption

func WithJoin added in v0.10.0

func WithJoin(p string) SendJsonOption

WithJoin 注意拼接顺序

func WithMethod added in v0.10.0

func WithMethod(m string) SendJsonOption

func WithValue added in v0.10.0

func WithValue(v map[string]string) SendJsonOption

Jump to

Keyboard shortcuts

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