2019-04-25 04:52:08 +07:00
|
|
|
package middlewares
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/valyala/fasthttp"
|
|
|
|
)
|
|
|
|
|
2022-06-14 14:20:13 +07:00
|
|
|
// LogRequest provides trace logging for all requests.
|
2022-05-03 09:19:30 +07:00
|
|
|
func LogRequest(next fasthttp.RequestHandler) fasthttp.RequestHandler {
|
2019-04-25 04:52:08 +07:00
|
|
|
return func(ctx *fasthttp.RequestCtx) {
|
2019-12-11 14:52:02 +07:00
|
|
|
autheliaCtx := &AutheliaCtx{RequestCtx: ctx}
|
|
|
|
logger := NewRequestLogger(autheliaCtx)
|
2019-04-25 04:52:08 +07:00
|
|
|
|
|
|
|
logger.Trace("Request hit")
|
|
|
|
next(ctx)
|
|
|
|
logger.Tracef("Replied (status=%d)", ctx.Response.StatusCode())
|
|
|
|
}
|
|
|
|
}
|