Documentation
¶
Index ¶
- Constants
- func GinLogFormatter(param gin.LogFormatterParams) string
- func Healthcheck(g *gin.Context)
- func LoggerMiddleware(logger *log.Logger) gin.HandlerFunc
- func ValidationMessages(err error) []string
- type AnalyticsConfig
- type AppConfig
- type AuthConfig
- type EmailData
- type Event
- type Health
- type LogConfig
- type MailConfig
- type RDBConfig
- type RecaptchaResponse
- type RecaptchaValidator
- type StatusMessage
- type WebConfig
Constants ¶
const ( HistoryTopic = "history" NotificationTopic = "notification" EmailSent = "email_sent" )
const ConfigFolder = "/etc/microsaas/"
Variables ¶
This section is empty.
Functions ¶
func GinLogFormatter ¶
func GinLogFormatter(param gin.LogFormatterParams) string
func Healthcheck ¶
Healthcheck is the REST handler for polling whether the application is available. @Summary Health check endpoint of the Schedlue.me app @Schemes @Description Returns the status and version of the application @Accept json @Produce json @Success 200 {object} common.Health @Router /healthcheck [get]
func LoggerMiddleware ¶
func LoggerMiddleware(logger *log.Logger) gin.HandlerFunc
func ValidationMessages ¶
ValidationMessages is a function to convert Gin-Gonic validation error to human readable.
Types ¶
type AnalyticsConfig ¶
type AnalyticsConfig struct {
StatsigServerKey string `mapstructure:"STATSIG_SERVER_SECRET_KEY"`
}
type AppConfig ¶
type AppConfig struct { DB *RDBConfig Auth *AuthConfig Log *LogConfig Mail *MailConfig Web *WebConfig Analytics *AnalyticsConfig Path string }
AppConfig is the holder of all configurations for the application
type AuthConfig ¶
type AuthConfig struct { JWTSecret string `mapstructure:"JWT_SIGN_SECRET"` JWTExp int `mapstructure:"JWT_EXPIRATION_HOURS"` JWTSecure bool `mapstructure:"JWT_COOKIE_SECURE"` TLSCert string `mapstructure:"TLS_CERT_PATH"` TLSKey string `mapstructure:"TLS_KEY_PATH"` FrontendRoot string `mapstructure:"FRONTEND_ROOT"` BackendRoot string `mapstructure:"BACKEND_ROOT"` RecaptchaAppCreds string `mapstructure:"GOOGLE_APPLICATION_CREDENTIALS"` RecaptchaProjectID string `mapstructure:"GOOGLE_PROJECT_ID"` RecaptchaKey string `mapstructure:"GOOGLE_RECAPTCHA_KEY"` GoogleKey string `mapstructure:"GOOGLE_AUTH_KEY"` GoogleSecret string `mapstructure:"GOOGLE_AUTH_SECRET"` FacebookKey string `mapstructure:"FACEBOOK_AUTH_KEY"` FacebookSecret string `mapstructure:"FACEBOOK_AUTH_SECRET"` }
AuthConfig is a configuration of the authentication.
type LogConfig ¶
type LogConfig struct { LogLevel string `mapstructure:"LOG_LEVEL"` PrettyLog bool `mapstructure:"PRETTY_LOG"` }
LogConfig is a configuration of the logging.
type MailConfig ¶
type MailConfig struct { ApplicationName string `mapstructure:"APPLICATION_NAME"` NoReplyAddress string `mapstructure:"MAIL_NO_REPLY_ADDRESS"` SMTPAddress string `mapstructure:"MAIL_SMTP_ADDRESS"` SMTPUser string `mapstructure:"MAIL_SMTP_USER"` SMTPPassword string `mapstructure:"MAIL_SMTP_PASSWORD"` SMTPPort int `mapstructure:"MAIL_SMTP_PORT"` }
MailConfig is a configuration of e-mail massaging.
type RDBConfig ¶
type RDBConfig struct { Host string `mapstructure:"DB_HOST"` Port int `mapstructure:"DB_PORT"` DBName string `mapstructure:"DB_NAME"` Username string `mapstructure:"DB_USER"` Password string `mapstructure:"DB_PASS"` MaxIdleConns int `mapstructure:"DB_MAX_IDLE_CONN"` MaxOpenConns int `mapstructure:"DB_MAX_OPEN_CONN"` ConnMaxLifetime time.Duration `mapstructure:"DB_CONN_LIFETIME"` SSLMode string `mapstructure:"DB_SSL_MODE"` SSLCert string `mapstructure:"DB_SSL_CERT"` }
RDBConfig is a configuration of the relational database.
type RecaptchaResponse ¶
type RecaptchaResponse struct { Success bool `json:"success"` Score float64 `json:"score"` Action string `json:"action"` ChallengeTS string `json:"challenge_ts"` Hostname string `json:"hostname"` ErrorCodes []string `json:"error-codes"` }
RecaptchaResponse is a JSON response from Google ReCaptcha.
type RecaptchaValidator ¶
type RecaptchaValidator struct {
// contains filtered or unexported fields
}
RecaptchaValidator is a struct for validating captcha using Google's ReCapthca validator
func NewRecaptchaValidator ¶
func NewRecaptchaValidator(projectID string, recaptchaKey string, keyFile string) (*RecaptchaValidator, error)
NewRecaptchaValidator is a function creating a new `RecaptchaValidator` based on the API secret
func (RecaptchaValidator) Close ¶
func (v RecaptchaValidator) Close()
func (RecaptchaValidator) Verify ¶
func (v RecaptchaValidator) Verify(token string) error
Verify is a method of `RecaptchaValidator` verifying the captch token from the frontend
type StatusMessage ¶
type StatusMessage struct {
Message string
}
StatusMessage is a generic JSON response containing the message for the HTTP status.
func ValidationMessage ¶
func ValidationMessage(err error) StatusMessage
ValidationMessage is a function to convert Gin-Gonic validation errors to `StatusMessage`.