Documentation
¶
Index ¶
- Constants
- Variables
- func AuthorMd5Decode(ak, userId string, nickname string, avatarUrl, accessKey string, secret string) error
- func AuthorMd5Encode(author *CrossAppAuthor, secret string, expire time.Duration) (string, error)
- func Base64Decode(base64Str string) (string, error)
- func Base64Encode(str string) string
- func DecodeURLComponent(str string) string
- func EncodeURIComponent(str string) string
- func FilterStrSlice(items []string, filter StrSliceFilter) []string
- func FilterStrSliceDuplicate(items []string, filter StrSliceFilter) []string
- func Iff(express bool, trueValue, failValue interface{}) interface{}
- func JsonDecode(jsonStr string, result interface{}) error
- func JsonEncode(value interface{}) (string, error)
- func JsonTryEncode(value interface{}) string
- func Md5(s string) string
- func NewTokenJwtAlg(name string) jwt.SigningMethod
- func ParseUrlQuery(urlQuery string) map[string]any
- func SafeCall(entry func())
- func SliceFilter[T any](rows []T, comparer func(v T, idx ...int) bool) []T
- func SliceFind[T any](rows []T, comparer func(v T, idx ...int) bool) *T
- func SliceFindIndex[T any](rows []T, comparer func(v T, idx ...int) bool) int
- func StrSliceFilterEmpty(rows *[]string) *[]string
- func StrVal(value interface{}) string
- type BaseAuthor
- type CrossAppAuthor
- type JwtTarget
- type JwtToken
- type JwtTokenOptions
- type SimpleBaseAuthor
- type StrSliceFilter
- type TokenPayload
Constants ¶
View Source
const ( DefaultJwtSecret = "607510af2d25158d055686c7" DefaultJwtExpSec = 60 * 60 * 24 )
Variables ¶
View Source
var DefaultJwtAlg = jwt.SigningMethodHS256
Functions ¶
func AuthorMd5Decode ¶
func AuthorMd5Decode(ak, userId string, nickname string, avatarUrl, accessKey string, secret string) error
AuthorMd5Decode 验证数据签名
func AuthorMd5Encode ¶
AuthorMd5Encode md5 密钥签名
func FilterStrSlice ¶
func FilterStrSlice(items []string, filter StrSliceFilter) []string
FilterStrSlice 过滤字符串数组
func FilterStrSliceDuplicate ¶
func FilterStrSliceDuplicate(items []string, filter StrSliceFilter) []string
FilterStrSliceDuplicate 去掉重复项,并按filter过滤返回结果
func NewTokenJwtAlg ¶
func NewTokenJwtAlg(name string) jwt.SigningMethod
func SliceFilter ¶
func SliceFindIndex ¶
SliceFindIndex 在slice中查找索引序号,不存在时返回-1
func StrSliceFilterEmpty ¶
Types ¶
type BaseAuthor ¶
type CrossAppAuthor ¶
type CrossAppAuthor struct { AK string `json:"ak"` SimpleBaseAuthor AvatarUrl string `json:"avatarUrl"` }
type JwtToken ¶
type JwtToken interface { EncodeJwtToken(author BaseAuthor, target *JwtTarget, tokenSecret ...string) (string, error) DecodeJwtToken(tokenStr string, author BaseAuthor, tokenSecret ...string) (BaseAuthor, *JwtTarget, error) }
func NewJwtToken ¶
func NewJwtToken(options *JwtTokenOptions) JwtToken
type JwtTokenOptions ¶
type SimpleBaseAuthor ¶
func (*SimpleBaseAuthor) GetNickname ¶
func (s *SimpleBaseAuthor) GetNickname() string
func (*SimpleBaseAuthor) GetUserId ¶
func (s *SimpleBaseAuthor) GetUserId() string
type StrSliceFilter ¶
type TokenPayload ¶
type TokenPayload struct { Payload BaseAuthor `json:"payload"` jwt.StandardClaims }
Source Files
¶
Click to show internal directories.
Click to hide internal directories.