Documentation ¶
Index ¶
- func FailOnPanic(t *testing.T)
- func MakeEmailTemplate(fileName string, content interface{}) *bytes.Buffer
- func RandomToken() string
- func ReadFormIntoStruct(request *http.Request, dest interface{}, ignoreMissing bool) error
- func ReadMapIntoStruct(src map[string][]string, dest interface{}, ignoreMissing bool) error
- func ReadQueryIntoStruct(request *http.Request, dest interface{}, ignoreMissing bool) error
- func RecoveryHandler(h http.Handler, l interface{}, ps bool) http.Handler
- func ToSnakeCase(str string) string
- type EmailDispatcher
- type StringSet
- func (set StringSet) Add(s string) StringSet
- func (set StringSet) Contains(s string) bool
- func (set StringSet) Difference(other StringSet) StringSet
- func (set StringSet) Intersect(other StringSet) StringSet
- func (set StringSet) IsSuperset(other StringSet) bool
- func (set StringSet) Len() int
- func (set *StringSet) Scan(src interface{}) error
- func (set StringSet) Strings() []string
- func (set StringSet) Union(other StringSet) StringSet
- func (set StringSet) Value() (driver.Value, error)
- type ValidationError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FailOnPanic ¶
FailOnPanic can be used in tests in order to recover from a panic and make a test fail.
func MakeEmailTemplate ¶
MakeEmailTemplate parses a given template into the main email layout template, applies the parsed template to the specified content object and returns the result as a bytes.Buffer.
func RandomToken ¶
func RandomToken() string
RandomToken returns a cryptographically strong random token string. The Token is generated from 512 random bits and encoded via base32.StdEncoding
func ReadFormIntoStruct ¶
ReadFormIntoStruct call ParseForm on the request and reads all form data into a struct with matching fields.
See ReadMapIntoStruct for more information.
func ReadMapIntoStruct ¶
ReadMapIntoStruct reads values from a map of string slices into a struct with matching fields and converts/parses it as needed. ReadMapIntoStruct tries to find matching fields using the original field name or the original name converted into its snake case equivalent.
Supported field types for the target struct are integers, floats, boolean and slices of strings. But the reader does not check whether a string representation of an int, or float actually fits into the destination field.
On errors the reader returns a ValidationError.
func ReadQueryIntoStruct ¶
ReadQueryIntoStruct reads request query parameters into a struct with matching fields. Single query values are interpreted as coma separated list of values.
See ReadMapIntoStruct for more information.
func RecoveryHandler ¶
RecoveryHandler recovers from a panic, writes an HTTP InternalServerError, logs the panic message to the defined logging mechanism and continues to the next handler.
func ToSnakeCase ¶
ToSnakeCase turns a CamelCase string into its snake_case equivalent.
Types ¶
type EmailDispatcher ¶
EmailDispatcher defines an interface for e-mail dispatch.
func NewEmailDispatcher ¶
func NewEmailDispatcher() EmailDispatcher
NewEmailDispatcher returns an instance of emailDispatcher. Dependent on the value of config.smtp.Mode the send method will print the e-mail content to the commandline (value "print"), do nothing (value "skip") or by default send an e-mail via smtp.SendMail.
type StringSet ¶
StringSet is a simple set implementation based on map.
func NewStringSet ¶
NewStringSet creates a new StringSet from a slice of strings.
func (StringSet) Difference ¶
Difference returns a new util.StringSet containing all elements which are not found in the other util.StringSet.
func (StringSet) Intersect ¶
Intersect returns a new set containing only the elements contained in both original sets
func (StringSet) IsSuperset ¶
IsSuperset returns true if the set is a superset of the other set.
type ValidationError ¶
ValidationError provides information about each field of a struct that failed.
func (*ValidationError) Error ¶
func (err *ValidationError) Error() string
Error implements Go error