utils

package
v0.0.0-...-2142fb5 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2025 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const EnvPrefix string = "USER_AUTH"

Variables

View Source
var ErrCouldNotHash error = errors.New("could generate hash of password")

Functions

func Encode

func Encode[T any](w http.ResponseWriter, status int, v T) error

func EncodeError

func EncodeError[T any](w http.ResponseWriter, status int, data T) error

func EncodeValidationError

func EncodeValidationError(w http.ResponseWriter, ves validator.ValidationErrors)

func GenerateSalt

func GenerateSalt() ([]byte, error)

func If

func If[T any](cond bool, tval, fval T) T

func IsPassword

func IsPassword(hashed, password, salt []byte) bool

func SaltyPassword

func SaltyPassword(password, salt []byte) ([]byte, error)

func ValidateReq

func ValidateReq[T any](w http.ResponseWriter, r *http.Request, vdt *validator.Validate, val *T) error

Types

type ConfigType

type ConfigType struct {
	LogLevel slog.Level
	Debug    bool
	Secret   []byte
	Host     string
	Port     string
	DbUrl    string
	RedisUrl string
}

func NewConf

func NewConf() *ConfigType

Get the singleton config

Jump to

Keyboard shortcuts

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