diff --git a/crates/server/src/admin/handlers/context.rs b/crates/server/src/admin/handlers/context.rs index ac2963c87..23ef17f28 100644 --- a/crates/server/src/admin/handlers/context.rs +++ b/crates/server/src/admin/handlers/context.rs @@ -82,8 +82,8 @@ pub struct GetContextUsersResponse { } pub async fn get_context_users_handler( - Path(context_id): Path, - Extension(state): Extension>, + Path(_context_id): Path, + Extension(_state): Extension>, ) -> impl IntoResponse { ApiResponse { payload: GetContextUsersResponse { diff --git a/crates/server/src/admin/handlers/root_keys.rs b/crates/server/src/admin/handlers/root_keys.rs index 77792cc3a..0e0c7559b 100644 --- a/crates/server/src/admin/handlers/root_keys.rs +++ b/crates/server/src/admin/handlers/root_keys.rs @@ -10,9 +10,8 @@ use serde::Serialize; use tracing::info; use super::add_client_key::transform_request; -use crate::admin::handlers::add_client_key::store_client_key; use crate::admin::service::{parse_api_error, AdminState, ApiError, ApiResponse}; -use crate::admin::storage::root_key::{add_root_key, get_root_keys}; +use crate::admin::storage::root_key::add_root_key; use crate::admin::utils::auth::validate_challenge; #[derive(Debug, Serialize)] diff --git a/crates/server/src/admin/service.rs b/crates/server/src/admin/service.rs index 486e75d59..349b23892 100644 --- a/crates/server/src/admin/service.rs +++ b/crates/server/src/admin/service.rs @@ -11,19 +11,10 @@ use calimero_store::Store; use libp2p::identity::Keypair; use serde::{Deserialize, Serialize}; use serde_json::json; -use tower_http::services::{ServeDir, ServeFile}; -use tower_http::set_status::SetStatus; use tower_sessions::{MemoryStore, SessionManagerLayer}; use tracing::info; -use super::handlers::add_client_key::add_client_key_handler; -use super::handlers::challenge::request_challenge_handler; -use super::handlers::context::{ - create_context_handler, delete_context_handler, get_context_handler, get_contexts_handler, - get_context_storage_handler, get_context_client_keys_handler, get_context_users_handler -}; -use super::handlers::fetch_did::fetch_did_handler; -use super::handlers::root_keys::create_root_key_handler; +use super::handlers; #[derive(Debug, Serialize, Deserialize)] pub struct AdminConfig { @@ -63,19 +54,43 @@ pub(crate) fn setup( let admin_router = Router::new() .route("/health", get(health_check_handler)) - .route("/root-key", post(create_root_key_handler)) - .route("/request-challenge", post(request_challenge_handler)) + .route( + "/root-key", + post(handlers::root_keys::create_root_key_handler), + ) + .route( + "/request-challenge", + post(handlers::challenge::request_challenge_handler), + ) .route("/install-application", post(install_application_handler)) .route("/applications", get(list_applications_handler)) - .route("/add-client-key", post(add_client_key_handler)) - .route("/did", get(fetch_did_handler)) - .route("/contexts", post(create_context_handler)) - .route("/contexts/:context_id", delete(delete_context_handler)) - .route("/contexts/:context_id", get(get_context_handler)) - .route("/contexts/:context_id/users", get(get_context_users_handler)) - .route("/contexts/:context_id/client-keys", get(get_context_client_keys_handler)) - .route("/contexts/:context_id/storage", get(get_context_storage_handler)) - .route("/contexts", get(get_contexts_handler)) + .route( + "/add-client-key", + post(handlers::add_client_key::add_client_key_handler), + ) + .route("/did", get(handlers::fetch_did::fetch_did_handler)) + .route("/contexts", post(handlers::context::create_context_handler)) + .route( + "/contexts/:context_id", + delete(handlers::context::delete_context_handler), + ) + .route( + "/contexts/:context_id", + get(handlers::context::get_context_handler), + ) + .route( + "/contexts/:context_id/users", + get(handlers::context::get_context_users_handler), + ) + .route( + "/contexts/:context_id/client-keys", + get(handlers::context::get_context_client_keys_handler), + ) + .route( + "/contexts/:context_id/storage", + get(handlers::context::get_context_storage_handler), + ) + .route("/contexts", get(handlers::context::get_contexts_handler)) .layer(Extension(shared_state)) .layer(session_layer); diff --git a/crates/server/src/admin/storage/root_key.rs b/crates/server/src/admin/storage/root_key.rs index 928bf3c09..9342b814b 100644 --- a/crates/server/src/admin/storage/root_key.rs +++ b/crates/server/src/admin/storage/root_key.rs @@ -6,14 +6,6 @@ use super::did::{get_or_create_did, update_did}; pub fn add_root_key(store: &Store, root_key: RootKey) -> eyre::Result { let mut did_document = get_or_create_did(store)?; - let serialized_root_key = match serde_json::to_string(&root_key) { - Ok(json) => json, - Err(err) => { - eprintln!("Serialization error: {}", err); - return Err(eyre::eyre!("Serialization error: {}", err)); - } - }; - if !did_document .root_keys .iter()