utils

package
v0.0.0-...-4c1f3c0 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2022 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultPerPage = 10
	DefaultPage    = 1
)

Variables

View Source
var (
	JwtSigningKey = "lol u thought this would be secure"
)

Functions

func ApplyMiddleware

func ApplyMiddleware(e *gin.Engine, logger *zap.Logger) *gin.Engine

func AuthenticateMiddleware

func AuthenticateMiddleware(c *gin.Context)

func ErrorHandler

func ErrorHandler(logger *zap.Logger) gin.HandlerFunc

ErrorHandler responds errors in a user-friendly format and logs them to the console.

func GeneratePaginationData

func GeneratePaginationData(prefix string, total int, pq PaginationQuery) api.PaginationData

func ValidatorFunc

func ValidatorFunc(c *gin.Context, message string, code int)

Types

type PaginationQuery

type PaginationQuery struct {
	PerPage int `form:"perPage" json:"perPage"`
	Page    int `form:"page" json:"page"`
}

func NewPaginationQuery

func NewPaginationQuery() PaginationQuery

func (PaginationQuery) Offset

func (pq PaginationQuery) Offset() int

func (*PaginationQuery) Read

func (pq *PaginationQuery) Read(ctx *gin.Context)

func (*PaginationQuery) ReadFromOptional

func (pq *PaginationQuery) ReadFromOptional(page *int, perPage *int)

type UserClaims

type UserClaims struct {
	jwt.RegisteredClaims
}

Jump to

Keyboard shortcuts

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