mirror of
https://github.com/cubixle/tuu.git
synced 2026-04-24 21:24:43 +01:00
updated example
This commit is contained in:
@@ -3,17 +3,20 @@ package examples
|
|||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin/render"
|
"github.com/gobuffalo/buffalo/render"
|
||||||
"github.com/lukerodham/tuu"
|
"github.com/lukerodham/tuu"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
// The render we currently use is the one built by gobuffalo.
|
||||||
|
r := render.New(render.Options{})
|
||||||
|
|
||||||
router := tuu.NewRouter()
|
router := tuu.NewRouter()
|
||||||
router.SetEnv("dev")
|
router.SetEnv("dev")
|
||||||
router.GET("/home", func(ctx tuu.Context) error {
|
router.GET("/home", func(ctx tuu.Context) error {
|
||||||
ctx.Set("template_data", "some value")
|
ctx.Set("template_data", "some value")
|
||||||
|
|
||||||
return ctx.Render(200, render.HTML("template_name.html"))
|
return ctx.Render(200, r.HTML("template_name.html"))
|
||||||
})
|
})
|
||||||
|
|
||||||
router.POST("/login", func(ctx tuu.Context) error {
|
router.POST("/login", func(ctx tuu.Context) error {
|
||||||
@@ -26,11 +29,13 @@ func main() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
app := tuu.New(router)
|
app := tuu.New(router)
|
||||||
if err := app.Serve(tuu.Config{
|
err := app.Serve(tuu.Config{
|
||||||
IPAddr: "127.0.0.1",
|
IPAddr: "127.0.0.1",
|
||||||
Port: "8080",
|
Port: "8080",
|
||||||
Env: "dev",
|
Env: "dev",
|
||||||
}); err != nil {
|
}
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user