1 Star 0 Fork 0

hh / iris

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
main.go 1.47 KB
一键复制 编辑 原始数据 按行查看 历史
package main
import "github.com/kataras/iris"
// $ go get -u github.com/shuLhan/go-bindata/...
// $ go-bindata ./public/...
// $ go build
// $ ./embedded-single-page-application-with-other-routes
func newApp() *iris.Application {
app := iris.New()
app.OnErrorCode(404, func(ctx iris.Context) {
ctx.Writef("404 not found here")
})
app.StaticEmbedded("/", "./public", Asset, AssetNames)
// Note:
// if you want a dynamic index page then see the file-server/embedded-single-page-application
// which is registering a view engine based on bindata as well and a root route.
app.Get("/ping", func(ctx iris.Context) {
ctx.WriteString("pong")
})
app.Get("/.well-known", func(ctx iris.Context) {
ctx.WriteString("well-known")
})
app.Get(".well-known/ready", func(ctx iris.Context) {
ctx.WriteString("ready")
})
app.Get(".well-known/live", func(ctx iris.Context) {
ctx.WriteString("live")
})
app.Get(".well-known/metrics", func(ctx iris.Context) {
ctx.Writef("metrics")
})
return app
}
func main() {
app := newApp()
// http://localhost:8080/index.html
// http://localhost:8080/app.js
// http://localhost:8080/css/main.css
//
// http://localhost:8080/ping
// http://localhost:8080/.well-known
// http://localhost:8080/.well-known/ready
// http://localhost:8080/.well-known/live
// http://localhost:8080/.well-known/metrics
//
// Remember: we could use the root wildcard `app.Get("/{param:path}")` and serve the files manually as well.
app.Run(iris.Addr(":8080"))
}
1
https://gitee.com/w1229748769/iris.git
git@gitee.com:w1229748769/iris.git
w1229748769
iris
iris
v11.1.1

搜索帮助