jwt

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2019 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 Msg) (string, error)
Example
s, err := Encode(Msg{1, "meng"})
if err != nil {
	fmt.Printf("%v\n", err)
}
ss := strings.Split(s, ".")
fmt.Println(ss[0])
r2 := Msg{}
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 Msg

type Msg struct {
	UserID   int32  `json:"userid"`
	UserName string `json:"username"`
}

func Decode

func Decode(tokenString string) (Msg, error)

type MyCustomClaims

type MyCustomClaims struct {
	Msg
	jwt.StandardClaims
}

Jump to

Keyboard shortcuts

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