jwtmiddleware

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2016 License: MIT Imports: 3 Imported by: 0

README

JSON WEB TOKEN Middleware

This middleware requires CleverGo JWT.

Install dependences

go get github.com/clevergo/jwt

About the usages of jwt package, please refer to https://github.com/clevergo/jwt.

Example

JSON WEB TOKEN Example

go run $GOPATH/src/github.com/headwindfly/clevergo/examples/jwt/main.go

Usage

Please refer to JSON WEB TOKEN Example.

Set Error Handler

JWTMiddleware.SetErrorHandler(handler clevergo.HandlerFunc)

Set Success Handler

JWTMiddleware.SetSuccessHandler(handler func(ctx *clevergo.Context, token *jwt.Token))

SuccessHandler is a useful handler, you can use it store the current user info in Context.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type JWTMiddleware

type JWTMiddleware struct {
	// contains filtered or unexported fields
}

JWTMiddleware JSON WEB TOKEN Middleware.

func NewJWTMiddleware

func NewJWTMiddleware(jwt *jwt.JWT) JWTMiddleware

NewJWTMiddleware returns JWT Middleware instance.

func (JWTMiddleware) Handle

Handle implemented Middleware Interface.

func (JWTMiddleware) Key

func (m JWTMiddleware) Key() string

Key returns key.

func (*JWTMiddleware) SetErrorHandler

func (m *JWTMiddleware) SetErrorHandler(handler clevergo.HandlerFunc)

SetErrorHandler for setting error handler.

func (*JWTMiddleware) SetKey

func (m *JWTMiddleware) SetKey(key string)

SetKey for setting key.

func (*JWTMiddleware) SetSuccessHandler

func (m *JWTMiddleware) SetSuccessHandler(handler func(ctx *clevergo.Context, token *jwt.Token))

SetSuccessHandler for setting success handler.

Jump to

Keyboard shortcuts

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