Documentation
¶
Index ¶
- Constants
- Variables
- func ConfigDecoderOptions(config *mapstructure.DecoderConfig)
- func HTTPRequestAccepts(r *http.Request, mime string) bool
- func JSONErrResponse(w http.ResponseWriter, err error, statusCode int)
- func JSONResponse(w http.ResponseWriter, v interface{}, statusCode int)
- func ParseJSONBody(v interface{}, w http.ResponseWriter, r *http.Request) error
- type Config
- type EmailUserInfo
- type Server
Constants ¶
View Source
const ( // EmailVerificationSubject is the subject for verification emails EmailVerificationSubject = "Netsoc account verification" // EmailResetPasswordSubject is the subject for password reset emails EmailResetPasswordSubject = "Netsoc account password reset" )
Variables ¶
View Source
var ( // EmailVerificationAPI is a template for an email with API-based verification EmailVerificationAPI = template.Must(template.New("email_verification.txt").Parse(`Hi {{.User.FirstName}}, Thanks for signing up to Netsoc! Here's your verification token: {{.Token}} Regards, The Netsoc Team `)) // EmailVerificationUI is a template for an email with UI-based verification EmailVerificationUI = template.Must(template.New("email_verification.txt").Parse(`Hi {{.User.FirstName}}, Thanks for signing up to Netsoc! Click the following link to verify your account: {{template "url" .}} Regards, The Netsoc Team `)) // EmailResetPasswordAPI is a template for an email with API-based password reset EmailResetPasswordAPI = template.Must(template.New("email_verification.txt").Parse(`Hi {{.User.FirstName}}, Here's your password reset token: {{.Token}} If you didn't initiate the reset, you can ignore this email. Regards, The Netsoc Team `)) // EmailResetPasswordUI is a template for an email with UI-based password reset EmailResetPasswordUI = template.Must(template.New("email_verification.txt").Parse(`Hi {{.User.FirstName}}, Click the following link to reset your password: {{template "url" .}} If you didn't initiate the reset, you can ignore this email. Regards, The Netsoc Team `)) )
Functions ¶
func ConfigDecoderOptions ¶
func ConfigDecoderOptions(config *mapstructure.DecoderConfig)
ConfigDecoderOptions enables necessary mapstructure decode hook functions
func HTTPRequestAccepts ¶
HTTPRequestAccepts returns true if the given request accepts the provided MIME type
func JSONErrResponse ¶
func JSONErrResponse(w http.ResponseWriter, err error, statusCode int)
JSONErrResponse Sends an `error` as a JSON object with a `message` property
func JSONResponse ¶
func JSONResponse(w http.ResponseWriter, v interface{}, statusCode int)
JSONResponse Sends a JSON payload in response to a HTTP request
func ParseJSONBody ¶
func ParseJSONBody(v interface{}, w http.ResponseWriter, r *http.Request) error
ParseJSONBody attempts to parse the request body as JSON
Types ¶
type Config ¶
type Config struct {
LogLevel log.Level `mapstructure:"log_level"`
PostgreSQL struct {
Host string
User string
Password string
PasswordFile string `mapstructure:"password_file"`
Database string
TimeZone string
DSNExtra string `mapstructure:"dsn_extra"`
SoftDelete bool `mapstructure:"soft_delete"`
}
Mail struct {
From string
ReplyTo string `mapstructure:"reply_to"`
VerifyURL string `mapstructure:"verify_url"`
ResetURL string `mapstructure:"reset_url"`
SMTP struct {
Host string
Port uint16
Username string
Password string
TLS bool
PasswordFile string `mapstructure:"password_file"`
}
}
HTTP struct {
ListenAddress string `mapstructure:"listen_address"`
CORS struct {
AllowedOrigins []string `mapstructure:"allowed_origins"`
}
}
JWT struct {
Key []byte `mapstructure:"key"`
KeyFile string `mapstructure:"key_file"`
Issuer string
LoginValidity time.Duration `mapstructure:"login_validity"`
EmailValidity time.Duration `mapstructure:"email_validity"`
}
RootPassword string `mapstructure:"root_password"`
RootPasswordFile string `mapstructure:"root_password_file"`
ReservedUsernames []string `mapstructure:"reserved_usernames"`
}
Config defines iamd's configuration
func (*Config) JWTKeyFunc ¶
JWTKeyFunc returns a function that will return the JWT key (for use with `jwt` package)
func (*Config) ReadSecrets ¶
ReadSecrets loads values for secret config options from files
type EmailUserInfo ¶
EmailUserInfo represents information available to email templates
Click to show internal directories.
Click to hide internal directories.