/middleware

Logging a HTTP request with Go

Primary LanguageGo

Goal

Simple structured logging middleware

Usage

slog.Info("starting", "port", port)

if err := http.ListenAndServe(":"+port, middleware.LogStatus(mux)); err != nil {
    slog.Error("error listening", err)
}