mirror of
https://github.com/kataras/iris.git
synced 2026-01-06 11:37:06 +00:00
Former-commit-id: 221e01638b671586cdab2b84518bd6a1c8d07bda
This commit is contained in:
@@ -12,7 +12,8 @@ import (
|
||||
// tested with redis version 3.0.503.
|
||||
// for windows see: https://github.com/ServiceStack/redis-windows
|
||||
func main() {
|
||||
// replace with your running redis' server settings:
|
||||
// These are the default values,
|
||||
// you can replace them based on your running redis' server settings:
|
||||
db := redis.New(redis.Config{
|
||||
Network: "tcp",
|
||||
Addr: "127.0.0.1:6379",
|
||||
@@ -25,14 +26,14 @@ func main() {
|
||||
Driver: redis.Redigo(), // redis.Radix() can be used instead.
|
||||
})
|
||||
|
||||
// optionally configure the underline driver:
|
||||
// Optionally configure the underline driver:
|
||||
// driver := redis.Redigo()
|
||||
// driver.MaxIdle = ...
|
||||
// driver.IdleTimeout = ...
|
||||
// driver.Wait = ...
|
||||
// redis.Config {Driver: driver}
|
||||
|
||||
// close connection when control+C/cmd+C
|
||||
// Close connection when control+C/cmd+C
|
||||
iris.RegisterOnInterrupt(func() {
|
||||
db.Close()
|
||||
})
|
||||
|
||||
@@ -114,10 +114,27 @@ func main() {
|
||||
ctx.View("todos/show.jet", todo)
|
||||
})
|
||||
app.Get("/all-done", func(ctx iris.Context) {
|
||||
vars := make(view.JetRuntimeVars) // <-- or keep use the jet.VarMap, decision up to you, it refers to the same type.
|
||||
vars.Set("showingAllDone", true)
|
||||
view.AddJetRuntimeVars(ctx, vars) // <--
|
||||
ctx.View("todos/index.jet", (&doneTODOs{}).New(todos))
|
||||
// vars := make(view.JetRuntimeVars)
|
||||
// vars.Set("showingAllDone", true)
|
||||
// vars.Set("title", "Todos - All Done")
|
||||
// view.AddJetRuntimeVars(ctx, vars)
|
||||
// ctx.View("todos/index.jet", (&doneTODOs{}).New(todos))
|
||||
//
|
||||
// OR
|
||||
|
||||
ctx.ViewData("showingAllDone", true)
|
||||
ctx.ViewData("title", "Todos - All Done")
|
||||
|
||||
// Key does not actual matters at all here.
|
||||
// However, you can enable it for better performance.
|
||||
// In order to enable key mapping for
|
||||
// jet specific renderer and ranger types
|
||||
// then initialize the View Engine
|
||||
// by `tmpl.DisableViewDataTypeCheck("_jet")`.
|
||||
//
|
||||
// Defaults to type checks, empty key.
|
||||
ctx.ViewData("_jet", (&doneTODOs{}).New(todos))
|
||||
ctx.View("todos/index.jet")
|
||||
})
|
||||
|
||||
port := os.Getenv("PORT")
|
||||
|
||||
Reference in New Issue
Block a user