2017-11-09 11:03:14 +01:00
|
|
|
package main
|
|
|
|
|
2019-10-25 00:27:02 +02:00
|
|
|
import "github.com/kataras/iris/v12"
|
2017-11-09 11:03:14 +01:00
|
|
|
|
2022-07-19 21:48:04 +02:00
|
|
|
// $ go install github.com/go-bindata/go-bindata/v3/go-bindata@latest
|
2020-07-24 12:03:49 +02:00
|
|
|
// $ go-bindata -fs -prefix "public" ./public/...
|
|
|
|
// $ go run .
|
2017-11-09 11:03:14 +01:00
|
|
|
|
|
|
|
func newApp() *iris.Application {
|
|
|
|
app := iris.New()
|
2019-06-21 18:43:25 +02:00
|
|
|
app.OnErrorCode(iris.StatusNotFound, func(ctx iris.Context) {
|
2017-11-09 11:03:14 +01:00
|
|
|
ctx.Writef("404 not found here")
|
|
|
|
})
|
|
|
|
|
2020-07-24 12:03:49 +02:00
|
|
|
app.HandleDir("/", AssetFile())
|
2017-11-09 11:03:14 +01:00
|
|
|
|
|
|
|
// 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.
|
2020-03-05 21:41:27 +01:00
|
|
|
app.Listen(":8080")
|
2017-11-09 11:03:14 +01:00
|
|
|
}
|