infrastructure

package
v0.30.0 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2023 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClosePostgresConnection

func ClosePostgresConnection()

func ErrorHandlerMiddleware

func ErrorHandlerMiddleware() gin.HandlerFunc

func GetPostgresConnection

func GetPostgresConnection() *sql.DB

func GetValidator

func GetValidator() *validator.Validate

func ParseISODate added in v0.29.0

func ParseISODate(date string) (time.Time, error)

func WithAuthenticationMiddleware added in v0.4.0

func WithAuthenticationMiddleware() gin.HandlerFunc

func WithAuthorizationMiddleware added in v0.4.0

func WithAuthorizationMiddleware(role []string) gin.HandlerFunc

Types

type Claims added in v0.3.0

type Claims struct {
	UUID string `json:"uuid"`
	Role string `json:"role"`
	jwt.RegisteredClaims
}

type EnvironmentSpec added in v0.5.1

type EnvironmentSpec struct {
	Environment        string `split_words:"true" default:"development"`
	DbConnectionString string `split_words:"true" default:"postgres://postgres:postgres@localhost:5432/codelabs?sslmode=disable"`
	DbMigrationsPath   string `split_words:"true" default:"file://sql/migrations"`
	JwtSecret          string `split_words:"true" default:"default"`
	JwtExpirationHours int    `split_words:"true" default:"6"`
	WebClientUrl       string `split_words:"true" default:"http://localhost:5173"`
}

func GetEnvironment

func GetEnvironment() *EnvironmentSpec

type JwtTokenHandler added in v0.3.0

type JwtTokenHandler struct {
	Secret          string
	ExpirationHours int
}

func GetJwtTokenHandler added in v0.3.0

func GetJwtTokenHandler() *JwtTokenHandler

func (JwtTokenHandler) GenerateToken added in v0.3.0

func (handler JwtTokenHandler) GenerateToken(user entities.User) (string, error)

func (JwtTokenHandler) ValidateToken added in v0.3.0

func (handler JwtTokenHandler) ValidateToken(token string) (dtos.CustomClaimsDTO, error)

Jump to

Keyboard shortcuts

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