hyperswitch-card-vault icon indicating copy to clipboard operation
hyperswitch-card-vault copied to clipboard

feat(error): handle json error as json instead of plaintext

Open NishantJoshi00 opened this issue 4 months ago • 0 comments

Description

This pull request includes several updates primarily focused on refactoring the use of the axum library and improving error handling. The most important changes include adding new dependencies, modifying error handling with JsonError, and updating various route handlers to use the new Json type.

Dependency Updates:

  • Cargo.toml: Added axum-extra and modified axum to include the macros feature.

Error Handling Improvements:

  • src/error.rs: Introduced JsonError struct and implemented From<JsonRejection> and IntoResponse for better error handling.
  • src/middleware.rs: Updated middleware to use error::Json for JSON extraction.

Route Handler Updates:

  • src/routes/data.rs: Refactored multiple route handlers (add_card, delete_card, retrieve_card, get_or_insert_fingerprint) to use error::Json for request extraction and axum::Json for responses. [1] [2] [3] [4]
  • src/routes/health.rs: Updated health check handlers to use axum::Json for responses. [1] [2]
  • src/routes/key_custodian.rs: Refactored key custodian route handlers (key1, key2, decrypt) to use error::Json for request extraction and axum::Json for responses. [1] [2] [3] [4]
  • src/routes/key_migration.rs: Updated transfer_keys handler to use error::Json for request extraction and axum::Json for responses. [1] [2]

NishantJoshi00 avatar Oct 04 '24 12:10 NishantJoshi00