apputil

package
v1.7.3 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2021 License: Apache-2.0 Imports: 11 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Trace   *log.Logger
	Info    *log.Logger
	Warning *log.Logger
	Error   *log.Logger
)

Package level variables, which are pointer to log.Logger.

Functions

func AuthorizeRequest

func AuthorizeRequest(next http.Handler) http.Handler

AuthorizeRequest Middleware validates JWT tokens from incoming HTTP requests.

func DisplayAppError

func DisplayAppError(w http.ResponseWriter, handlerError error, message string, code int)

DisplayAppError provides app specific error in JSON

func GenerateJWT

func GenerateJWT(name, role string) (string, error)

GenerateJWT generates a new JWT token for authenticated user.

func InitRSAKeys

func InitRSAKeys()

InitRSAKeys reads the key files to be used for JWT

func SetLogLevel

func SetLogLevel(level Level)

SetLogLevel sets the logging level preference

Types

type AppClaims

type AppClaims struct {
	UserName string `json:"username"`
	Role     string `json:"role"`
	jwt.StandardClaims
}

AppClaims provides custom claim for JWT

type Level

type Level int

Level holds the log level.

const (
	// UNSPECIFIED logs nothing
	UNSPECIFIED Level = iota // 0 :
	// TRACE logs everything
	TRACE // 1
	// INFO logs Info, Warnings and Errors
	INFO // 2
	// WARNING logs Warning and Errors
	WARNING // 3
	// ERROR just logs Errors
	ERROR // 4
)

Jump to

Keyboard shortcuts

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