代码拉取完成,页面将自动刷新
package main
import (
"github.com/kataras/iris"
)
func main() {
app := iris.New()
templates := iris.HTML("./views", ".html").Layout("shared/layout.html")
app.RegisterView(templates)
app.Controller("/", new(Controller))
// http://localhost:9091
app.Run(iris.Addr(":9091"))
}
// Layout contains all the binding properties for the shared/layout.html
type Layout struct {
Title string
}
// Controller is our example controller.
type Controller struct {
iris.Controller
Layout Layout `iris:"model"`
}
// BeginRequest is the first method fires when client requests from this Controller's path.
func (c *Controller) BeginRequest(ctx iris.Context) {
c.Controller.BeginRequest(ctx)
c.Layout.Title = "Home Page"
}
// Get handles GET http://localhost:9091
func (c *Controller) Get() {
c.Tmpl = "index.html"
c.Data["Message"] = "Welcome to my website!"
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。