25 lines
512 B
Go
25 lines
512 B
Go
package eia
|
|
|
|
import (
|
|
"context"
|
|
"net/http"
|
|
"time"
|
|
|
|
"github.com/rs/zerolog"
|
|
|
|
eiaapi "gitea.libretechconsulting.com/50W/eia-api-go/api"
|
|
)
|
|
|
|
func newLoggingMiddleware(logger *zerolog.Logger, level zerolog.Level) eiaapi.RequestEditorFn {
|
|
return func(_ context.Context, req *http.Request) error {
|
|
logger.WithLevel(level).
|
|
Str("method", req.Method).
|
|
Str("host", req.URL.Host).
|
|
Str("path", req.URL.Path).
|
|
Str("query", req.Form.Encode()).
|
|
Time("timestamp", time.Now()).
|
|
Send()
|
|
return nil
|
|
}
|
|
}
|