utils

package
v0.0.0-...-e2fe045 Latest Latest
Warning

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

Go to latest
Published: May 1, 2024 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidAGS       = errors.New("invalid ags")
	ErrLocationNotFound = errors.New("location not found")
)

Functions

func AppendCtx

func AppendCtx(parent context.Context, attr []slog.Attr) context.Context

AppendCtx adds an slog attribute to the provided context so that it will be included in any Record created with such context

func BackstepAGS

func BackstepAGS(ags string) string

func CalculateAge

func CalculateAge(birthYear int64) (int64, error)

func CheckboxFormatBool

func CheckboxFormatBool(value bool) string

func FormFormatLaws

func FormFormatLaws(laws []*models.Law) []string

func FormFormatProblems

func FormFormatProblems(problems []*models.Problem) []string

func FullHost

func FullHost(r *http.Request, cfg *config.Config, path string) string

func FullUrl

func FullUrl(r *http.Request, cfg *config.Config) string

func If

func If[T any](cond bool, vtrue, vfalse T) T

func LimitChars

func LimitChars(text string, limit int) string

func MakeSQLNullInt64

func MakeSQLNullInt64(value int64) sql.NullInt64

func MakeSQLNullString

func MakeSQLNullString(value string) sql.NullString

func PrintLocationName

func PrintLocationName(ags_part string, name string) string

func RandomEmail

func RandomEmail() string

RandomEmail generates a random email

func RandomString

func RandomString(n int) string

RandomString generates a random string of length n

func RandomTokenKey

func RandomTokenKey() string

RandomTokenKey generates a random keyt for PASETO V4 Token

func RandomUsername

func RandomUsername() string

RandomUsername generates a random user name

func SetServiceCtx

func SetServiceCtx(parent context.Context, value string) context.Context

SetServiceCtx adds the slog attribute "service" to the provided context so that it will be included in any Record created with such context

func SplitAGS

func SplitAGS(input string) [5]string

Types

type ContextHandler

type ContextHandler struct {
	slog.Handler
}

func (ContextHandler) Handle

func (h ContextHandler) Handle(ctx context.Context, r slog.Record) error

Handle adds contextual attributes to the Record before calling the underlying handler

Jump to

Keyboard shortcuts

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