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())) } }
func versionHandler(ctx *golf.Context) { appVersion, _ := ctx.App.Config.GetString("APP/VERSION", "unavailable") ctx.Send(appVersion) }
func homeHandler(ctx *golf.Context) { apiKey, _ := ctx.App.Config.GetString("API_KEY", "0") ctx.Send(apiKey) }
func loginHandlerPost(ctx *golf.Context) { ctx.Session.Set("name", ctx.Request.FormValue("name")) ctx.Send("Hi, " + ctx.Request.FormValue("name")) }
func loginHandler(ctx *golf.Context) { ctx.Loader("default").Render("login.html", make(map[string]interface{})) }
func mainHandler(ctx *golf.Context) { ctx.Send("Hello World!") }