1 Star 0 Fork 0

sonysoul/iris

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
main.go 1.00 KB
一键复制 编辑 原始数据 按行查看 历史
Frédéric Meyer 提交于 2018-02-21 08:18 . Save
package main
import (
"github.com/kataras/iris"
)
func main() {
app := iris.New()
none := app.None("/invisible/{username}", func(ctx iris.Context) {
ctx.Writef("Hello %s with method: %s", ctx.Params().Get("username"), ctx.Method())
if from := ctx.Values().GetString("from"); from != "" {
ctx.Writef("\nI see that you're coming from %s", from)
}
})
app.Get("/change", func(ctx iris.Context) {
if none.IsOnline() {
none.Method = iris.MethodNone
} else {
none.Method = iris.MethodGet
}
// refresh re-builds the router at serve-time in order to be notified for its new routes.
app.RefreshRouter()
})
app.Get("/execute", func(ctx iris.Context) {
// same as navigating to "http://localhost:8080/invisible/iris" when /change has being invoked and route state changed
// from "offline" to "online"
ctx.Values().Set("from", "/execute") // values and session can be shared when calling Exec from a "foreign" context.
ctx.Exec("GET", "/invisible/iris")
})
app.Run(iris.Addr(":8080"))
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/sonysoul/iris.git
git@gitee.com:sonysoul/iris.git
sonysoul
iris
iris
v10.6.5

搜索帮助