web

package
v0.0.0-...-d9989c3 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2015 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var RequestHandlerFunc http.HandlerFunc = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
	log.Println("in translation handler")
	defer context.Clear(r)

	session := getSession(r)

	context.Set(r, "session", session)

	data := getDefaultTemplateData(r)
	context.Set(r, "data", data)

	setTranslateFuncs(r, data)

	if UserSessionHandler != nil {
		UserSessionHandler(r, session)
	}

	sessionConfig.Routes.ServeHTTP(w, r)
})
View Source
var UserSessionHandler func(r *http.Request, session *sessions.Session)

Functions

func GetFileServer

func GetFileServer(config FileServerConfig) httprouter.Handle

func GetFutureT

func GetFutureT(r *http.Request) i18n.FutureTranslateFunc

func GetSession

func GetSession(r *http.Request) *sessions.Session

func GetStaticPath

func GetStaticPath(path string) string

func GetTemplate

func GetTemplate(name string, r *http.Request) *template.Template

func InitSessions

func InitSessions(config SessionConfig)

func InitTemplates

func InitTemplates(config TemplateConfig)

func SendResponse

func SendResponse(templateName string, r *http.Request, w http.ResponseWriter)

Types

type FileServerConfig

type FileServerConfig struct {
	Asset           func(name string) ([]byte, error)
	AssetDir        func(name string) ([]string, error)
	StaticFilesPath string
}

type SessionConfig

type SessionConfig struct {
	Routes http.Handler
	Secret string
}

type TemplateConfig

type TemplateConfig struct {
	Asset func(name string) ([]byte, error)
	Root  string
}

type TemplateData

type TemplateData map[string]interface{}

func GetTemplateData

func GetTemplateData(r *http.Request) TemplateData

Jump to

Keyboard shortcuts

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