add HTTPStatus helper

This commit is contained in:
Pavel 2023-10-18 15:19:01 +03:00
parent b97f05e666
commit 4c1f29ba01

View File

@ -1,6 +1,9 @@
package logger
import "log/slog"
import (
"log/slog"
"net/http"
)
const (
HandlerAttr = "handler"
@ -20,3 +23,7 @@ func ErrAttr(err any) slog.Attr {
}
return slog.Any(ErrorAttr, err)
}
func HTTPStatus(code int) (slog.Attr, slog.Attr) {
return slog.Int(HTTPStatusAttr, code), slog.String(HTTPStatusNameAttr, http.StatusText(code))
}