harden drives api and improve logging

This commit is contained in:
Michael Barz
2022-10-13 15:59:30 +02:00
parent a275c1c4ef
commit 0b7297d1b4
13 changed files with 438 additions and 192 deletions

View File

@@ -50,6 +50,8 @@ const (
QuotaLimitReached
// Unauthenticated the caller is not authenticated.
Unauthenticated
// PreconditionFailed the request cannot be made and this error response is sent back
PreconditionFailed
)
var errorCodes = [...]string{
@@ -69,6 +71,7 @@ var errorCodes = [...]string{
"serviceNotAvailable",
"quotaLimitReached",
"unauthenticated",
"preconditionFailed",
}
func New(e ErrorCode, msg string) Error {
@@ -82,7 +85,6 @@ func New(e ErrorCode, msg string) Error {
func (e ErrorCode) Render(w http.ResponseWriter, r *http.Request, status int, msg string) {
innererror := map[string]interface{}{
"date": time.Now().UTC().Format(time.RFC3339),
// TODO return client-request-id?
}
innererror["request-id"] = middleware.GetReqID(r.Context())