mirror of
https://github.com/kataras/iris.git
synced 2025-01-23 18:51:03 +01:00
3945fa68d1
We have to do the same on iris-contrib/examples, iris-contrib/middleware and e.t.c. Former-commit-id: 0860688158f374bc137bc934b81b26dcd0e10964
30 lines
695 B
Go
30 lines
695 B
Go
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.Gzip(true)
|
|
ctx.ViewData("", mypage{"My Page title", "Hello world!"})
|
|
ctx.View("mypage.html")
|
|
// 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.Run(iris.Addr(":8080"))
|
|
}
|