Documentation ¶
Overview ¶
Package webapp provides a set of convenient functions for Go based web applications.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DetermineLocale ¶ added in v1.0.3
DetermineLocale tries to find the best locale for a given input from a list of available locales. It applies the following logic:
- If the input can be directly found in list of available locales, it will be returned directly.
- If a less specific value is available, then it will be returned. E.g. if the input is zh-tw but zh is available then zh will be returned
- Otherwise an empty string is returned.
func DetermineLocaleWithDefault ¶ added in v1.0.4
DetermineLocaleWithDefault tries to find the best locale for a given input from a list of available locales. It applies the following logic:
- If the input can be directly found in list of available locales, it will be returned directly.
- If a less specific value is available, then it will be returned. E.g. if the input is zh-tw but zh is available then zh will be returned
- If no locale can be found, the first entry in available will be returned. If available is empty, an empty string will be returned. It is down to the caller of the function to handle such situation.
func GetTemplate ¶
GetTemplate loads the template from the given path. The funtion caches the loaded template so that the same template would not be parsed over and over again unless skipCache is set to true.
Please note this method panics if template.ParseFiles failes in any way.
func HSTSHandler ¶
func HSTSHandler(f http.HandlerFunc) http.HandlerFunc
HSTSHandler takes a normal HTTP handler and adds the capability of sending HSTS headers.
Types ¶
This section is empty.