1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-18 02:17:05 +00:00

simplify some examples

This commit is contained in:
Gerasimos (Makis) Maropoulos
2020-11-07 12:49:14 +02:00
parent 7a19cfb211
commit 7b6a8f1e26
17 changed files with 55 additions and 172 deletions

View File

@@ -1,27 +1,15 @@
package main
import (
"github.com/kataras/iris/v12"
)
// same as embedded-single-page-application but without go-bindata, the files are "physical" stored in the
// current system directory.
var page = struct {
Title string
}{"Welcome"}
import "github.com/kataras/iris/v12"
func newApp() *iris.Application {
app := iris.New()
app.RegisterView(iris.HTML("./public", ".html"))
app.Get("/", func(ctx iris.Context) {
ctx.ViewData("Page", page)
ctx.View("index.html")
app.HandleDir("/", iris.Dir("./public"), iris.DirOptions{
IndexName: "index.html",
SPA: true,
})
app.HandleDir("/", iris.Dir("./public"))
return app
}
@@ -29,8 +17,7 @@ func main() {
app := newApp()
// http://localhost:8080
// http://localhost:8080/index.html
// http://localhost:8080/app.js
// http://localhost:8080/css/main.css
// http://localhost:8080/about
// http://localhost:8080/a_notfound
app.Listen(":8080")
}