add Body helper

This commit is contained in:
Pavel 2023-10-18 15:30:01 +03:00
parent 57d7084b74
commit 8eb0d6b31f

View File

@ -12,6 +12,7 @@ const (
CounterIDAttr = "counterId" CounterIDAttr = "counterId"
ErrorAttr = "error" ErrorAttr = "error"
FailureMessageAttr = "failureMessage" FailureMessageAttr = "failureMessage"
BodyAttr = "body"
HTTPMethodAttr = "httpMethod" HTTPMethodAttr = "httpMethod"
HTTPStatusAttr = "httpStatusCode" HTTPStatusAttr = "httpStatusCode"
HTTPStatusNameAttr = "httpStatusName" HTTPStatusNameAttr = "httpStatusName"
@ -27,3 +28,7 @@ func ErrAttr(err any) slog.Attr {
func HTTPStatus(code int) []any { func HTTPStatus(code int) []any {
return []any{slog.Int(HTTPStatusAttr, code), slog.String(HTTPStatusNameAttr, http.StatusText(code))} return []any{slog.Int(HTTPStatusAttr, code), slog.String(HTTPStatusNameAttr, http.StatusText(code))}
} }
func Body(val any) slog.Attr {
return slog.Any(BodyAttr, val)
}