giredore/internal/httpserver/requestlogger.go
Stanislav N. aka pztrn 83a8694061
Server and client stubs.
Implemented HTTP server with configuration getting stub.

Implemented CLI client with configuration getting stub.
2019-10-05 21:53:22 +05:00

25 lines
520 B
Go

package httpserver
import (
// other
"github.com/labstack/echo"
)
func requestLogger() echo.MiddlewareFunc {
return func(next echo.HandlerFunc) echo.HandlerFunc {
return func(ec echo.Context) error {
log.Info().
Str("From", ec.RealIP()).
Str("To", ec.Request().Host).
Str("Method", ec.Request().Method).
Str("Path", ec.Request().URL.Path).
Int64("Length", ec.Request().ContentLength).
Str("UA", ec.Request().UserAgent()).
Msg("HTTP request")
_ = next(ec)
return nil
}
}
}