infrastructure

package
v0.37.0 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2023 License: AGPL-3.0 Imports: 20 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)

ParseISODate parses a date in ISO format received from a date-time input

func ParseMicroserviceError added in v0.35.0

func ParseMicroserviceError(resp *http.Response, err error) error

ParseMicroserviceError parses the error returned by the archives microservice

func ValidateMultipartFileHeader added in v0.37.0

func ValidateMultipartFileHeader(multipartHeader *multipart.FileHeader) error

ValidateMultipartFileHeader validates the multipart archive according to the environment configuration and domain rules

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 {
	// Execution environment
	Environment string `split_words:"true" default:"development"`

	// Connection strings
	DbConnectionString             string `split_words:"true" default:"postgres://postgres:postgres@localhost:5432/codelabs?sslmode=disable"`
	WebClientUrl                   string `split_words:"true" default:"http://localhost:5173"`
	StaticFilesMicroserviceAddress string `split_words:"true" default:"http://localhost:8081"`

	// PgSQL migration files
	DbMigrationsPath string `split_words:"true" default:"file://sql/migrations"`

	// JWT parameters
	JwtSecret          string `split_words:"true" default:"default"`
	JwtExpirationHours int    `split_words:"true" default:"6"`

	// Configuration parameters
	ArchiveMaxSizeKb int64 `split_words:"true" default:"1024"`
}

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