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 StrReplaceSearch(str string, startStr, endStr string, replace SubReplacer) string
- func StrSliceFilterEmpty(rows *[]string) *[]string
- func StrSliceIndexOf(items []string, substr string) int
- func StrVal(value interface{}) string
- type BaseAuthor
- type CrossAppAuthor
- type JwtTarget
- type JwtToken
- type JwtTokenOptions
- type SimpleBaseAuthor
- type SimpleJwtOptions
- type SimpleJwtToken
- type SimpleTokenPayload
- type StrScanner
- type StrSliceFilter
- type SubReplacer
- type SubStrIndex
- type TokenPayload
Constants ¶
View Source
const ( DefaultJwtSecret = "607510af2d25158d055686c7" DefaultJwtExpSec = 60 * 60 * 24 )
Variables ¶
View Source
var DefaultJwtAlg = jwt.SigningMethodHS256
View Source
var DefaultJwtOptions = SimpleJwtOptions{
TokenJwtExpSec: 60 * 60 * 30,
TokenJwtAlg: "HS256",
TokenJwtSecret: "123456789",
}
View Source
var SimJwtToken = &SimpleJwtToken{}
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 StrReplaceSearch ¶ added in v0.0.4
func StrReplaceSearch(str string, startStr, endStr string, replace SubReplacer) string
func StrSliceFilterEmpty ¶
func StrSliceIndexOf ¶ added in v0.0.5
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 SimpleJwtOptions ¶ added in v0.0.5
type SimpleJwtToken ¶ added in v0.0.5
type SimpleJwtToken struct { }
func (*SimpleJwtToken) Decode ¶ added in v0.0.5
func (jt *SimpleJwtToken) Decode(tokenStr string, opts *SimpleJwtOptions) (interface{}, *JwtTarget, error)
Decode 验证token
func (*SimpleJwtToken) Encode ¶ added in v0.0.5
func (jt *SimpleJwtToken) Encode(payload interface{}, target *JwtTarget, opts *SimpleJwtOptions) (string, error)
Encode 生成token
type SimpleTokenPayload ¶ added in v0.0.5
type SimpleTokenPayload struct { Payload interface{} `json:"payload"` jwt.StandardClaims }
type StrScanner ¶ added in v0.0.4
type StrScanner interface { Next() bool Prev() bool Read(readLen int) string ReadRune() *rune Current() int Inc(step int) Dec(step int) }
func NewStrScanner ¶ added in v0.0.4
func NewStrScanner(str string) StrScanner
type StrSliceFilter ¶
type SubReplacer ¶ added in v0.0.4
type SubStrIndex ¶ added in v0.0.4
func StrSearchSubs ¶ added in v0.0.4
func StrSearchSubs(str string, startStr, endStr string) []*SubStrIndex
func (*SubStrIndex) String ¶ added in v0.0.4
func (si *SubStrIndex) String() string
type TokenPayload ¶
type TokenPayload struct { Payload BaseAuthor `json:"payload"` jwt.StandardClaims }
Source Files ¶
Click to show internal directories.
Click to hide internal directories.