-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
/
main.go
32 lines (26 loc) · 775 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package main
import (
"github.com/kataras/iris/v12"
)
type mypage struct {
Title string
Message string
}
func main() {
app := iris.New()
app.RegisterView(iris.HTML("./templates", ".html").Layout("layout.html"))
// TIP: append .Reload(true) to reload the templates on each request.
app.Get("/", func(ctx iris.Context) {
ctx.CompressWriter(true)
ctx.ViewData("", mypage{"My Page title", "Hello world!"})
if err := ctx.View("mypage.html"); err != nil {
ctx.HTML("<h3>%s</h3>", err.Error())
return
}
// Note that: you can pass "layout" : "otherLayout.html" to bypass the config's Layout property
// or view.NoLayout to disable layout on this render action.
// third is an optional parameter
})
// http://localhost:8080
app.Listen(":8080")
}