Documentation ¶
Overview ¶
Package utils gathers various useful stuff
All listing or list-like information, usually cross-packages, are all gathered in this package in order to have a centralized location for information such as - Error codes list - Email account configuration and templates - Environment variables name
Index ¶
Constants ¶
const ( // EmailTemplateUserRegistration when sending email for new user EmailTemplateUserRegistration = "user_registration" // EmailTemplateUserPwdReset when user is requesting a password reset EmailTemplateUserPwdReset = "user_pwd-reset" )
const ( // === Server EnvVarServerPort = "ALUN_SERVER_MONOLITHIC_PORT" EnvVarServerIsMonolithic = "ALUN_SERVER_IS_MONOLITHIC" EnvVarMode = "ALUN_MODE" // === Application: User EnvVarUserPort = "ALUN_USER_PORT" EnvVarUserDbURL = "ALUN_USER_DATABASE_URL" EnvVarUserSaltPwd = "ALUN_SECRET_PWD" EnvVarUserSaltJwt = "ALUN_SECRET_JWT" // === Application: Memo EnvVarMemoPort = "ALUN_MEMO_PORT" EnvVarMemoDbURL = "ALUN_MEMO_DATABASE_URL" // === Email EnvVarEmailUsername = "ALUN_EMAIL_USERNAME" EnvVarEmailPassword = "ALUN_EMAIL_PASSWORD" EnvVarEmailHost = "ALUN_EMAIL_HOST" EnvVarEmailPort = "ALUN_EMAIL_PORT" EnvVarEmailSender = "ALUN_EMAIL_SENDER" )
List all environment variable names here to have a centralized list
const ( AlunModeDev = "Development" AlunModeTest = "Test" AlunModeProd = "Production" )
List all running mode of the applications
Variables ¶
This section is empty.
Functions ¶
func IsDev ¶
func IsDev() bool
IsDev returns true if the environment variables define a Development mode
Types ¶
type AlunEmail ¶
type AlunEmail struct { Account communication.EmailConfiguration Sender string TemplateFolder string }
AlunEmail is the default production implementation of AlunEmailSender
func (AlunEmail) SendNoReplyEmail ¶
func (ae AlunEmail) SendNoReplyEmail(to []string, subject string, templateName string, emailData interface{}) error
SendNoReplyEmail sends an email from a no-reply account.
The returned error is only for telling the calling method that something went wrong. Parent method is not expected to tell the error content to the client and error handling must be done by checking the logs.
If templateName does not end up with `.html`, it is automatically appended
type AlunEmailSender ¶
type AlunEmailSender interface {
SendNoReplyEmail(to []string, subject string, templateName string, emailData interface{}) error
}
AlunEmailSender is a convenient interface to send an email from a specific no-reply Alun email
type DummyEmail ¶
type DummyEmail struct { }
DummyEmail prevents from sending real email and does nothing
func GetDummyEmail ¶
func GetDummyEmail() *DummyEmail
GetDummyEmail generates a DummyEmail and keep the GetXXX singleton syntax to align with LoadAlunEmail
func (DummyEmail) SendNoReplyEmail ¶
func (de DummyEmail) SendNoReplyEmail(to []string, subject string, templateName string, emailData interface{}) error
SendNoReplyEmail does nothing