iris/_examples/view/template_html_1/main.go
Gerasimos (Makis) Maropoulos 0f113dfcda (#1554) Add support for all common compressions (write and read)
- Remove the context.Context interface and export the *context, the iris.Context now points to the pointer\nSupport compression and rate limiting in the FileServer\nBit of code organisation


Former-commit-id: ad1c61bf968059510c6be9e7f2cceec7da70ba17
2020-07-10 23:21:09 +03:00

30 lines
691 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.Compress(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.Listen(":8080")
}