forked from kataras/iris
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
28 lines (21 loc) · 643 Bytes
/
main.go
File metadata and controls
28 lines (21 loc) · 643 Bytes
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
package main
import (
"github.com/kataras/iris"
)
func main() {
app := iris.New()
app.OnErrorCode(iris.StatusInternalServerError, func(ctx iris.Context) {
ctx.HTML("Message: <b>" + ctx.Values().GetString("message") + "</b>")
})
app.Get("/", func(ctx iris.Context) {
ctx.HTML(`Click <a href="/my500">here</a> to fire the 500 status code`)
})
app.Get("/my500", func(ctx iris.Context) {
ctx.Values().Set("message", "this is the error message")
ctx.StatusCode(500)
})
app.Get("/u/{firstname:alphabetical}", func(ctx iris.Context) {
ctx.Writef("Hello %s", ctx.Params().Get("firstname"))
})
app.Run(iris.Addr(":8080"))
}