Skip to content

Commit

Permalink
feat(endpoints): add ActionMetadata in mod.rs and integrate into upda…
Browse files Browse the repository at this point in the history
…te and delete responses

- Define ActionMetadata struct in src/endpoints/mod.rs for shared use
- Extend ClientUpdateResponse and ClientDeleteResponse to include ActionMetadata
- Update both delete and update handlers to populate metadata with action details (timestamp, user, client_id)
  • Loading branch information
Mehrn0ush committed Oct 26, 2024
1 parent adfaec8 commit 3e0aa48
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/core/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,22 @@ pub enum RegistrationError {
InvalidRequest,
InvalidGrant,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct ActionMetadata {
pub action_timestamp: String,
pub performed_by: String,
pub client_id: String,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct ClientDeleteResponse {
pub message: String,
pub metadata: ActionMetadata,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct ClientUpdateResponse {
pub message: String,
pub metadata: ActionMetadata,
}
2 changes: 2 additions & 0 deletions src/endpoints/delete.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
use crate::auth::rbac::rbac_check;
use crate::core::token::TokenStore;
use crate::core::types::{ActionMetadata, ClientUpdateResponse as CoreClientUpdateResponse};
use crate::endpoints::register::Client as RegisterClient;
use crate::endpoints::update::Client as UpdateClient;
use crate::endpoints::update::ClientStore;
use actix_web::{web, HttpRequest, HttpResponse, Responder};
use actix_web_httpauth::extractors::bearer::BearerAuth;
use chrono::Utc;
use serde::{Deserialize, Serialize};
use std::sync::{Arc, RwLock};

Expand Down
2 changes: 2 additions & 0 deletions src/endpoints/update.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
use crate::core::token::InMemoryTokenStore;
use crate::core::token::TokenStore;
use crate::core::types::{ActionMetadata, ClientUpdateResponse as CoreClientUpdateResponse};
use actix_web::{web, HttpRequest, HttpResponse, Responder};
use actix_web_httpauth::extractors::bearer::BearerAuth;
use chrono::Utc;
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use std::sync::RwLock;
Expand Down

0 comments on commit 3e0aa48

Please sign in to comment.