User list

This commit is contained in:
Eden Kirin
2023-10-25 19:54:21 +02:00
parent 34b2f55cfc
commit b143983d52
10 changed files with 160 additions and 34 deletions

View File

@ -3,9 +3,11 @@ package main
import (
"fmt"
"iris-test/app/views"
"os"
"time"
"github.com/kataras/iris/v12"
"github.com/kataras/iris/v12/middleware/accesslog"
"github.com/kataras/iris/v12/sessions"
"github.com/kataras/iris/v12/sessions/sessiondb/redis"
)
@ -41,10 +43,49 @@ func createSessionEngine() *sessions.Sessions {
return sessions_engine
}
func createAccessLog() *accesslog.AccessLog {
// Initialize a new access log middleware.
ac := accesslog.New(os.Stdout)
// Remove this line to disable logging to console:
// ac.AddOutput(os.Stdout)
// The default configuration:
ac.Delim = '|'
ac.TimeFormat = "2006-01-02 15:04:05"
ac.Async = false
ac.IP = true
ac.BytesReceivedBody = true
ac.BytesSentBody = true
ac.BytesReceived = false
ac.BytesSent = false
ac.BodyMinify = true
ac.RequestBody = true
ac.ResponseBody = false
ac.KeepMultiLineError = true
ac.PanicLog = accesslog.LogHandler
// Default line format if formatter is missing:
// Time|Latency|Code|Method|Path|IP|Path Params Query Fields|Bytes Received|Bytes Sent|Request|Response|
//
// Set Custom Formatter:
ac.SetFormatter(&accesslog.JSON{
Indent: " ",
HumanTime: true,
})
// ac.SetFormatter(&accesslog.CSV{})
// ac.SetFormatter(&accesslog.Template{Text: "{{.Code}}"})
return ac
}
func createApp() *iris.Application {
sessions_engine := createSessionEngine()
sessionsEngine := createSessionEngine()
accessLog := createAccessLog()
app := iris.New()
app.Use(sessions_engine.Handler())
app.Logger().SetLevel(Config.Application.LogLevel)
app.Use(sessionsEngine.Handler())
app.UseRouter(accessLog.Handler)
app.RegisterView(iris.Jet("./app/templates", ".jet").Reload(true))
views.CreateRouter(app)
return app