mdw

package module
v0.0.0-...-20c9e53 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2024 License: MIT Imports: 7 Imported by: 0

README

mdw

gin middleware

note

Before using the middleware, please remember to init headerName secret & expire.

Here is the example:

    mdw.SetSecret("balabala..")
	mdw.SetHeaderName("xxx")
	mdw.SetJWTExpire(20) //20 seconds

Full example can be seen here

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllowCrossOrigin

func AllowCrossOrigin() gin.HandlerFunc

func AuthRequired

func AuthRequired() gin.HandlerFunc

AuthRequired jwt

func CreateJWT

func CreateJWT(uid int) (string, error)

create jwt token with user id

func GetUid

func GetUid(c *gin.Context) int

get user id

func SetHeaderName

func SetHeaderName(str string)

func SetJWTExpire

func SetJWTExpire(i int64)

jwt expire time

func SetSecret

func SetSecret(str string)

secret

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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