-
-
Notifications
You must be signed in to change notification settings - Fork 176
/
main.go
41 lines (32 loc) · 829 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package main
import "github.com/kataras/iris/v12"
func main() {
app := iris.New()
// Read about its syntax at: https://github.com/kataras/blocks
app.RegisterView(iris.Blocks("./views", ".html").Reload(true))
app.Get("/", index)
app.Get("/500", internalServerError)
app.Listen(":8080")
}
func index(ctx iris.Context) {
data := iris.Map{
"Title": "Page Title",
}
ctx.ViewLayout("main")
if err := ctx.View("index", data); err != nil {
ctx.HTML("<h3>%s</h3>", err.Error())
return
}
}
func internalServerError(ctx iris.Context) {
ctx.StatusCode(iris.StatusInternalServerError)
data := iris.Map{
"Code": iris.StatusInternalServerError,
"Message": "Internal Server Error",
}
ctx.ViewLayout("error")
if err := ctx.View("500", data); err != nil {
ctx.HTML("<h3>%s</h3>", err.Error())
return
}
}