utils

package
v0.2.56 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 6, 2020 License: MIT Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MODE_DEV        = "dev"
	MODE_BETA       = "beta"
	MODE_PROD       = "prod"
	LOG_ROTATE_SIZE = 10000
	LOG_FILENAME    = "sso.log"
)

Variables

View Source
var AddressForbidden error = errors.New("address forbidden")
View Source
var CfgDisableConfigWatch = false
View Source
var CfgFileName string = ""
View Source
var CfgHash = ""
View Source
var ClientCfg map[string]string = map[string]string{}
View Source
var ClientCfgHash = ""

Functions

func AddConfigListener

func AddConfigListener(listener func(*model.Config, *model.Config)) string

func DisableConfigWatch

func DisableConfigWatch()

func DisableDebugLogForTest

func DisableDebugLogForTest()

func EnableConfigFromEnviromentVars

func EnableConfigFromEnviromentVars()

func EnableConfigWatch

func EnableConfigWatch()

func EnableDebugLogForTest

func EnableDebugLogForTest()

func FileExistsInConfigFolder

func FileExistsInConfigFolder(filename string) bool

func FindConfigFile

func FindConfigFile(fileName string) string

func FindDir

func FindDir(dir string) (string, bool)

func GetDisplayName

func GetDisplayName(user *model.User) string

func GetHostnameFromSiteURL

func GetHostnameFromSiteURL(siteURL string) string

func GetIpAddress

func GetIpAddress(r *http.Request) string

func GetLogFileLocation

func GetLogFileLocation(fileLocation string) string

func GetSiteURL

func GetSiteURL() string

func GetSupportedLocales

func GetSupportedLocales() map[string]string

func GetTranslationsAndLocale

func GetTranslationsAndLocale(w http.ResponseWriter, r *http.Request) (i18n.TranslateFunc, string)

func GetTranslationsBySystemLocale

func GetTranslationsBySystemLocale() (i18n.TranslateFunc, error)

func GetUserTranslations

func GetUserTranslations(locale string) i18n.TranslateFunc

func HttpClient

func HttpClient(trustURLs bool) *http.Client

func InitAndLoadConfig

func InitAndLoadConfig(filename string) error

func InitHTML

func InitHTML()

func InitHTMLWithDir

func InitHTMLWithDir(dir string)

func InitTranslations

func InitTranslations(localizationSettings model.LocalizationSettings) error

func InitTranslationsWithDir

func InitTranslationsWithDir(dir string) error

func InitializeConfigWatch

func InitializeConfigWatch()

func IsPasswordValid

func IsPasswordValid(password string) *model.AppError

func LoadConfig

func LoadConfig(fileName string)

func MapToJson

func MapToJson(objmap map[string]string) string

func RegenerateClientConfig

func RegenerateClientConfig()

func RemoveConfigListener

func RemoveConfigListener(id string)

func RemoveDuplicatesFromStringArray

func RemoveDuplicatesFromStringArray(arr []string) []string

func RenderWebError

func RenderWebError(err *model.AppError, w http.ResponseWriter, r *http.Request)

func SaveConfig

func SaveConfig(fileName string, config *model.Config) *model.AppError

func SendMail

func SendMail(to, subject, body string) *model.AppError

func SendMailUsingConfig

func SendMailUsingConfig(to, subject, body string, config *model.Config) *model.AppError

func SetDefaultRolesBasedOnConfig

func SetDefaultRolesBasedOnConfig()

func SetSiteURL

func SetSiteURL(url string)

func SetTranslations

func SetTranslations(locale string) i18n.TranslateFunc

func StringArrayContains

func StringArrayContains(arr1, arr2 []string) bool

func StringArrayIntersection

func StringArrayIntersection(arr1, arr2 []string) []string

func TfuncWithFallback

func TfuncWithFallback(pref string) i18n.TranslateFunc

func TranslationsPreInit

func TranslationsPreInit() error

func UrlEncode

func UrlEncode(str string) string

func ValidateLocales

func ValidateLocales(cfg *model.Config) *model.AppError

Types

type Cache

type Cache struct {
	// contains filtered or unexported fields
}

func NewLru

func NewLru(size int) *Cache

func NewLruWithEvict

func NewLruWithEvict(size int, onEvicted func(key interface{}, value interface{})) (*Cache, error)

func (*Cache) Add

func (c *Cache) Add(key, value interface{}) bool

func (*Cache) AddWithExpiresInSecs

func (c *Cache) AddWithExpiresInSecs(key, value interface{}, expireAtSecs int64) bool

func (*Cache) Get

func (c *Cache) Get(key interface{}) (value interface{}, ok bool)

func (*Cache) Keys

func (c *Cache) Keys() []interface{}

func (*Cache) Len

func (c *Cache) Len() int

func (*Cache) Purge

func (c *Cache) Purge()

func (*Cache) Remove

func (c *Cache) Remove(key interface{})

func (*Cache) RemoveOldest

func (c *Cache) RemoveOldest()

type DialContextFunction

type DialContextFunction func(ctx context.Context, network, addr string) (net.Conn, error)

type HTMLTemplate

type HTMLTemplate struct {
	TemplateName string
	Props        map[string]interface{}
	Html         map[string]template.HTML
	Locale       string
}

func NewHTMLTemplate

func NewHTMLTemplate(templateName string, locale string) *HTMLTemplate

func (*HTMLTemplate) Render

func (t *HTMLTemplate) Render() string

func (*HTMLTemplate) RenderToWriter

func (t *HTMLTemplate) RenderToWriter(w http.ResponseWriter) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL