Пример #1
0
func createCookieStoreWithRandomKey() *sessions.CookieStore {
	var authenticationKey = securecookie.GenerateRandomKey(cookieAuthenticationKeyLengthInBytes)
	if authenticationKey == nil {
		log.Fatalf(
			"failed to generate random cookie authentication key of %d bytes",
			cookieAuthenticationKeyLengthInBytes)
	}
	return sessions.NewCookieStore(authenticationKey)
}
Пример #2
0
Файл: gone.go Проект: fxnn/gone
func exportTemplates(cfg config.Config) {
	var target = templatePath(contentRoot(), cfg)
	if target.IsEmpty() {
		target = contentRoot().JoinPath(defaultTemplateDirectoryName)
	}

	if err := templates.NewStaticLoader().WriteAllTemplates(target); err != nil {
		log.Fatalf("error exporting templates: %s", err)
	}
}
Пример #3
0
Файл: gone.go Проект: fxnn/gone
func templatePath(contentRoot gopath.GoPath, cfg config.Config) (result gopath.GoPath) {
	// configuration
	result = gopath.FromPath(cfg.TemplatePath)
	if !result.IsEmpty() {
		if !result.IsDirectory() {
			log.Fatalf("configured template path is no directory: %s", result.Path())
		}
		log.Printf("using templates from %s (by configuration)", result.Path())
		return result
	}

	// convention
	result = contentRoot.JoinPath(defaultTemplateDirectoryName)
	if result.IsDirectory() {
		log.Printf("using templates from %s (by convention)", result.Path())
		return result
	}

	// default
	log.Printf("using default templates")
	return gopath.Empty()
}