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