1
0
mirror of https://github.com/kataras/iris.git synced 2026-01-09 13:05:56 +00:00

minor: godoc

This commit is contained in:
Gerasimos (Makis) Maropoulos
2020-08-30 17:18:04 +03:00
parent 65e60df44e
commit 8b28ae14f8
4 changed files with 67 additions and 21 deletions

View File

@@ -1,6 +1,9 @@
package main
import "github.com/kataras/iris/v12"
import (
"github.com/kataras/iris/v12"
"github.com/kataras/iris/v12/mvc"
)
func main() {
app := iris.New()
@@ -28,8 +31,9 @@ func main() {
ctx.View("example.html", viewData)
})
/* See context-view-data example: Set data through one or more middleware
app.Get("/view_data", func(ctx iris.Context) {
exampleRouter := app.Party("/example")
/* See context-view-data example: Set data through one or more middleware */
exampleRouter.Use(func(ctx iris.Context) {
ctx.ViewData("author", map[string]string{"firstName": "Jean", "lastName": "Valjean"})
ctx.ViewData("body", "Life is difficult")
ctx.ViewData("comments", []iris.Map{{
@@ -37,14 +41,35 @@ func main() {
"body": "LOL!",
}})
// OR:
// ctx.ViewData("", iris.Map{
// "author": map[string]string{"firstName": "Jean", "lastName": "Valjean"},
// "body": "Life is difficult",
// "comments": []iris.Map{{
// "author": map[string]string{"firstName": "Marcel", "lastName": "Beliveau"},
// "body": "LOL!",
// }},
// })
ctx.Next()
}, func(ctx iris.Context) {
ctx.View("example.html")
})
*/
mvc.New(exampleRouter).Handle(new(controller))
// Read more about its syntax at:
// https://github.com/aymerick/raymond and
// https://handlebarsjs.com/guide
// http://localhost:8080
// http://localhost:8080/example
app.Listen(":8080")
}
type controller struct{}
func (c *controller) Get() mvc.Result {
return mvc.View{
Name: "example",
Code: 200,
}
}