2020-09-12 11:34:59 +02:00
|
|
|
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")
|
2020-09-13 01:56:22 +02:00
|
|
|
ac.ResponseBody = true
|
2020-09-13 13:28:05 +02:00
|
|
|
ac.LatencyRound = time.Second
|
2020-09-12 11:34:59 +02:00
|
|
|
ac.SetFormatter(&accesslog.CSV{
|
2020-09-13 01:56:22 +02:00
|
|
|
Header: true,
|
2020-09-12 11:34:59 +02:00
|
|
|
// 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")
|
|
|
|
}
|