mirror of
https://github.com/kataras/iris.git
synced 2025-02-02 23:40:35 +01:00
f487cd0029
Former-commit-id: 98895c34115ec2076b431332f0ffe9645adf7590
40 lines
861 B
Go
40 lines
861 B
Go
package main
|
|
|
|
import (
|
|
"gopkg.in/kataras/iris.v6"
|
|
"gopkg.in/kataras/iris.v6/adaptors/httprouter"
|
|
"gopkg.in/kataras/iris.v6/adaptors/view"
|
|
)
|
|
|
|
// Todo bind struct
|
|
type Todo struct {
|
|
Task string
|
|
Done bool
|
|
}
|
|
|
|
func main() {
|
|
// Configuration is optional
|
|
app := iris.New(iris.Configuration{Gzip: false, Charset: "UTF-8"})
|
|
|
|
// Adapt a logger which will print all errors to os.Stdout
|
|
app.Adapt(iris.DevLogger())
|
|
|
|
// Adapt the httprouter (we will use that on all examples)
|
|
app.Adapt(httprouter.New())
|
|
|
|
// Parse all files inside `./mytemplates` directory ending with `.html`
|
|
app.Adapt(view.HTML("./mytemplates", ".html"))
|
|
|
|
todos := []Todo{
|
|
{"Learn Go", true},
|
|
{"Read GopherBOOk", true},
|
|
{"Create a web app in Go", false},
|
|
}
|
|
|
|
app.Get("/", func(ctx *iris.Context) {
|
|
ctx.Render("todos.html", struct{ Todos []Todo }{todos})
|
|
})
|
|
|
|
app.Listen(":8080")
|
|
}
|