core

package
v0.0.0-...-eb64f0e Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2018 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	InvalidUID = int32(-1)

	ClaimsKey = "user"
)

Variables

View Source
var (
	// TokenHMACKey used to validate token.
	// Note: This variable must be initialized before attach JWT middleware
	// to HTTP Entrypoint.
	TokenHMACKey string

	// Defines a URL map to skip JWT validation on the specified route.
	URLMap map[string]struct{}
)

Functions

func GetUID

func GetUID(c *server.Context) int32

GetUID extract uid from context.

func InitHMACKey

func InitHMACKey(key string)

InitHMACKey initialize TokenHMACKey.

func JwtErrHandler

func JwtErrHandler(w http.ResponseWriter, r *http.Request, err string)

JwtErrHandler -

func NewToken

func NewToken(uid int32) (string, string, error)

NewToken generates a JWT token based on uid.

func Skipper

func Skipper(path string) bool

Skipper -

func WriteStatusAndDataJSON

func WriteStatusAndDataJSON(ctx *server.Context, status int, data interface{}) error

WriteStatusAndDataJSON send JSON encoding status (and data) response. The data is optional.

func WriteStatusAndIDJSON

func WriteStatusAndIDJSON(ctx *server.Context, status int, id interface{}) error

WriteStatusAndIDJSON send JSON encoding status and id response.

Types

This section is empty.

Jump to

Keyboard shortcuts

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