-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Expand file tree
/
Copy pathmain.go
More file actions
33 lines (25 loc) · 563 Bytes
/
main.go
File metadata and controls
33 lines (25 loc) · 563 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
29
30
31
32
33
package main
import "github.com/kataras/iris/v12"
func main() {
app := newApp()
app.Logger().SetLevel("debug")
app.Listen(":8080")
}
func newApp() *iris.Application {
app := iris.New()
app.HandleMany(iris.MethodGet, "/ /api/{page:string suffix(.html)}", handler1)
app.Get("/api/{name:string suffix(.zip)}", handler2)
return app
}
func handler1(ctx iris.Context) {
reply(ctx)
}
func handler2(ctx iris.Context) {
reply(ctx)
}
func reply(ctx iris.Context) {
ctx.JSON(iris.Map{
"handler": ctx.HandlerName(),
"params": ctx.Params().Store,
})
}