1 Star 0 Fork 0

hh/iris

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
main.go 868 Bytes
一键复制 编辑 原始数据 按行查看 历史
kataras 提交于 2017-08-28 12:26 . Add a simple Caddy+Iris tutorial :+1:
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!"
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/w1229748769/iris.git
git@gitee.com:w1229748769/iris.git
w1229748769
iris
iris
v8.4.2

搜索帮助