-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Expand file tree
/
Copy pathmain.go
More file actions
34 lines (27 loc) · 603 Bytes
/
main.go
File metadata and controls
34 lines (27 loc) · 603 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
34
package main
import (
"time"
"github.com/kataras/iris/v12"
"github.com/kataras/iris/v12/middleware/accesslog"
)
func main() {
app := iris.New()
ac := accesslog.File("access_log.csv")
ac.ResponseBody = true
ac.LatencyRound = time.Second
ac.SetFormatter(&accesslog.CSV{
Header: true,
// DateScript: "FROM_UNIX",
})
app.UseRouter(ac.Handler)
app.Get("/", index)
app.Listen(":8080")
}
func index(ctx iris.Context) {
if sleepDur := ctx.URLParam("sleep"); sleepDur != "" {
if d, err := time.ParseDuration(sleepDur); err == nil {
time.Sleep(d)
}
}
ctx.WriteString("Index")
}