jwt

package
v0.0.0-...-08c2887 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2018 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Encode

func Encode(r JWTMsg) (string, error)
Example
s, err := Encode(JWTMsg{1, "meng"})
if err != nil {
	fmt.Printf("%v\n", err)
}
ss := strings.Split(s, ".")
fmt.Println(ss[0])
r2 := JWTMsg{}
r2, err = Decode(s)
if err != nil {
	fmt.Printf("%v\n", err)
}
fmt.Println(r2.UserId)
fmt.Println(r2.UserName)
Output:

eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9
1
meng

Types

type JWTMsg

type JWTMsg struct {
	UserId   int32  `json:"userid"`
	UserName string `json:"username"`
}

func Decode

func Decode(tokenString string) (JWTMsg, error)

type MyCustomClaims

type MyCustomClaims struct {
	JWTMsg
	jwt.StandardClaims
}

Jump to

Keyboard shortcuts

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