Documentation
¶
Index ¶
- Constants
- func AllConfigKeys() []string
- func DecryptAES(secure string) (decoded string, err error)
- func EncryptAES(message string) (string, error)
- func GetLocale(ctx context.Context) (language string, currency string)
- func IsEmailCorrect(email string) bool
- func IsNameCorrect(name string) bool
- func IsPasswordCorrect(pwd string) bool
- func IsURLSafe(input string) bool
- func Ptr[T any](v T) *T
- type Config
- type HTTPConfig
- type MiddlewareConfig
- type MongoConfig
- type PostgresConfig
- type ValkeyConfig
Constants ¶
const ( PROJECT_NAME = "PROJECT_NAME" FILE_SERVER_PATH = "FILE_SERVER_PATH" AES_SECRET = "AES_SECRET" USE_DB_MONGO = "USE_DB_MONGO" USE_DB_POSTGRES = "USE_DB_POSTGRES" USE_DB_VALKEY = "USE_DB_VALKEY" USE_JS_ALPINE = "USE_JS_ALPINE" USE_MW_LOCALISATION = "USE_MW_LOCALISATION" USE_MW_SECURE_HEADERS = "USE_MW_SECURE_HEADERS" USE_MW_RATE_LIMIT = "USE_MW_RATE_LIMIT" MW_RATE_LIMITER_LIMIT = "MW_RATE_LIMITER_LIMIT" MW_RATE_LIMITER_BURST = "MW_RATE_LIMITER_BURST" USE_MW_LOG_AND_MONITOR_HEADERS = "USE_MW_LOG_AND_MONITOR_HEADERS" USE_MW_CORS = "USE_MW_CORS" USE_MW_ETAG = "USE_MW_ETAG" USE_MW_VALIDATE_SANITISE_HEADERS = "USE_MW_VALIDATE_SANITISE_HEADERS" USE_MW_METHOD_OVERRIDE = "USE_MW_METHOD_OVERRIDE" HTTP_PORT = "HTTP_PORT" MONGO_DB_NAME = "MONGO_DB_NAME" MONGO_USERNAME = "MONGO_USERNAME" MONGO_PASSWORD = "MONGO_PASSWORD" MONGO_HOST = "MONGO_HOST" MONGO_PORT = "MONGO_PORT" )
const ( MIN_NAME_LEN = 2 MIN_PASSWORD_LEN = 8 MAX_NAME_LEN = 64 MAX_PASSWORD_LEN = 32 )
This is a standard configuration. Modify these to your needs.
Variables ¶
This section is empty.
Functions ¶
func AllConfigKeys ¶
func AllConfigKeys() []string
func DecryptAES ¶
Decrypt encrypted message using AES encryption. Make sure AES_SECRET key with value was added to environmental variables.
func EncryptAES ¶
Encrypt string message using AES encryption. Make sure AES_SECRET key with value was added to environmental variables.
func IsEmailCorrect ¶
This email validation method is bit more advanced than a simple regex. If, for any reason, this configuration will be too much (or less likely too little) for your project, modify this function by adding/removing advanced conditions or regex itself.
func IsNameCorrect ¶
Quickly validate name/surname with the min/max system lenghts
func IsPasswordCorrect ¶
Validate if password has correct lenght, has at least one number, uppercased, and special character
Types ¶
type Config ¶
type Config struct { HTTP *HTTPConfig Middleware *MiddlewareConfig Mongo *MongoConfig Postgres *PostgresConfig Valkey *ValkeyConfig }
Holds global configuration sourced from local .env file
func NewDefaultConfig ¶
Create new default config from the local .env file. If any part of the configuration will cause an error, will return an empty config (nil) and error message
type HTTPConfig ¶
Configuration required for HTTP server
type MiddlewareConfig ¶
type MongoConfig ¶
Required configuration for creating mongodb connection
func (*MongoConfig) ConnectionString ¶
func (c *MongoConfig) ConnectionString() string
type PostgresConfig ¶
type PostgresConfig struct{}
Required configuration for creating postgres connection
type ValkeyConfig ¶
type ValkeyConfig struct{}
Required configuration for creating valkey connection