helpers

package
v0.0.0-...-3dc2a1c Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConfigValidation

func ConfigValidation() error

ConfigValidation validates the configuration settings.

This function checks the validity of various configuration settings such as the secret key, master username, master password, domain URL, domain HTTP schema, and server timezone. It returns an error if any of the configuration settings are invalid.

Returns: - error: An error indicating the invalid configuration setting, or nil if all settings are valid.

func DatetimeChecker

func DatetimeChecker(a, b time.Time) bool

DatetimeChecker compares two datetimes and returns true if they are equal or a is after b.

func DecryptString

func DecryptString(secretKey, encryptedText string) (string, error)

DecryptString decrypts a string that was encrypted using AES encryption with a given secret key.

func EncryptString

func EncryptString(secretKey, text string) (string, error)

EncryptString encrypts a string using AES encryption with a given secret key. It generates a random initialization vector (IV), encrypts the text using AES in CBC mode, appends the IV to the ciphertext, and returns the ciphertext as a hexadecimal string.

func ExpiresDatetimeSwitcher

func ExpiresDatetimeSwitcher(now time.Time, duration string) (time.Time, error)

ExpiresDatetimeSwitcher returns a new datetime with a duration.

func GenerateQRCode

func GenerateQRCode(text string, size int) (barcode.Barcode, error)

GenerateQRCode generates a QR code image from a given text and size.

func Getenv

func Getenv(key, fallback string) string

Getenv returns the value of the environment variable associated with the given key.

func HashString

func HashString(size int, s ...string) string

ShortenString shortens a string to a specified length using SHA256 hash.

func IsExistInFolder

func IsExistInFolder(name string, isFolder bool) bool

isExistInFolder searches for a file or folder by the given name in the current folder.

func IsSecretKeyValid

func IsSecretKeyValid(key string, length int) error

IsSecretKeyValid returns nil if the given secret key is valid.

func IsValidURL

func IsValidURL(uri string) error

IsValidURL returns nil if the given URL is valid.

func StaticFileServerHandler

func StaticFileServerHandler(efs embed.FS) http.Handler

StaticFileServerHandler handles a custom handler for serving static files from the embed static folder.

func ValidateAddSecretForm

func ValidateAddSecretForm(name, value string) (errorFields []*messages.ErrorField)

ValidateAddSecretForm returns nil if the given add secret form values are valid.

func ValidateUserSignInForm

func ValidateUserSignInForm(username, masterPassword string) (errorFields []*messages.ErrorField)

ValidateUserSignInForm returns nil if the given user sign in form values are valid.

func ValidateViewSecretForm

func ValidateViewSecretForm(accessCode string) (errorFields []*messages.ErrorField)

ValidateViewSecretForm returns nil if the given view secret form access code is valid.

func WrapHTTPError

func WrapHTTPError(w http.ResponseWriter, r *http.Request, status int, errTemplate templ.Component, errMsg string)

WrapHTTPError wraps HTTP errors.

Types

type ErrorField

type ErrorField struct {
	Name, Message string
}

ErrorField represents an error field.

Jump to

Keyboard shortcuts

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