jsonError writes a {"message": ...} error body with the given status code and a correct application/json content type.
(w http.ResponseWriter, code int, message string)
| 89 | // jsonError writes a {"message": ...} error body with the given status code |
| 90 | // and a correct application/json content type. |
| 91 | func jsonError(w http.ResponseWriter, code int, message string) { |
| 92 | w.Header().Set("Content-Type", "application/json") |
| 93 | w.WriteHeader(code) |
| 94 | if err := json.NewEncoder(w).Encode(map[string]string{"message": message}); err != nil { |
| 95 | zap.L().Error("Failed to write error response", zap.Error(err)) |
| 96 | } |
| 97 | } |
| 98 | |
| 99 | // authorizeSecretAccess enforces RequireAuth for secret retrieval and |
| 100 | // deletion. It writes the error response and audit event itself and reports |
no test coverage detected