Exemple #1
0
func mainHandler(ctx *golf.Context) {
	name, err := ctx.Session.Get("name")
	ctx.SetHeader("Content-Type", "text/html;charset=UTF-8")
	if err != nil {
		ctx.Send("Hello World! Please <a href=\"/login\">log in</a>. Current sessions: " + strconv.Itoa(ctx.App.SessionManager.Count()))
	} else {
		ctx.Send("Hello " + name.(string) + ". Current sessions: " + strconv.Itoa(ctx.App.SessionManager.Count()))
	}
}
Exemple #2
0
func versionHandler(ctx *golf.Context) {
	appVersion, _ := ctx.App.Config.GetString("APP/VERSION", "unavailable")
	ctx.Send(appVersion)
}
Exemple #3
0
func homeHandler(ctx *golf.Context) {
	apiKey, _ := ctx.App.Config.GetString("API_KEY", "0")
	ctx.Send(apiKey)
}
Exemple #4
0
func loginHandlerPost(ctx *golf.Context) {
	ctx.Session.Set("name", ctx.Request.FormValue("name"))
	ctx.Send("Hi, " + ctx.Request.FormValue("name"))
}
Exemple #5
0
func loginHandler(ctx *golf.Context) {
	ctx.Loader("default").Render("login.html", make(map[string]interface{}))
}
Exemple #6
0
func mainHandler(ctx *golf.Context) {
	ctx.Send("Hello World!")
}