middleware

package
v0.0.0-...-1580491 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2020 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateMarshal

func GenerateMarshal(groups []string, structModel interface{}) (interface{}, error)

GenerateMarshal function to generate marshal interface

func ResponseDefaultError

func ResponseDefaultError(c *gin.Context, err error)

ResponseDefaultError function

Types

type App

type App struct {
	Router *gin.Engine
	DB1    *db.DB1
}

App struct

func (*App) GenerateError

func (app *App) GenerateError(c *gin.Context, err error)

GenerateError to generate error output

func (*App) GetDB

func (app *App) GetDB() error

GetDB function to get a database connection

func (*App) ResponseHandler

func (app *App) ResponseHandler(f func(*gin.Context, *App) (interface{}, string, error)) gin.HandlerFunc

ResponseHandler function to handle response data from controller

func (*App) ValidateInput

func (app *App) ValidateInput(validationName string) gin.HandlerFunc

ValidateInput function

func (*App) ValidateUser

func (app *App) ValidateUser(validationName string) gin.HandlerFunc

ValidateUser to validate user route

type Claims

type Claims struct {
	MemberID uuid.UUID
	jwt.StandardClaims
}

Claims struct

type MemberToken

type MemberToken struct {
	Member model.Member
	Token  Token
}

MemberToken struct

func GenerateToken

func GenerateToken(member model.Member) (MemberToken, error)

GenerateToken function

type Output

type Output struct {
	Ctx        *gin.Context
	Err        error
	Group      string
	StructData interface{}
	App        *App
}

Output struct

func (Output) Handler

func (output Output) Handler()

Handler function to handle JSON response output

type Token

type Token struct {
	Value    string    `valid:"stringlength(10|100000)~TOKEN_VALUE_INVALID" json:"value" groups:"login"`
	MemberID uuid.UUID `json:"memberID" groups:""`
	Expire   time.Time `json:"expire" groups:"login"`
}

Token struct

func (Token) Refresh

func (token Token) Refresh(app *App) (MemberToken, error)

Refresh function to refresh token - not done

func (Token) Validate

func (token Token) Validate(app *App) (MemberToken, error)

Validate function to validate token

Jump to

Keyboard shortcuts

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