Skip to content

Commit 9092e62

Browse files
committed
feat(api): implement all apikeys routes
1 parent e07a489 commit 9092e62

2 files changed

Lines changed: 22 additions & 0 deletions

File tree

rustmail/src/api/routes/apikeys.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
use crate::prelude::api::*;
2+
use crate::prelude::types::*;
3+
use axum::Router;
4+
use axum::routing::{delete, get, post};
5+
use std::sync::Arc;
6+
use tokio::sync::Mutex;
7+
8+
pub fn create_apikeys_router(bot_state: Arc<Mutex<BotState>>) -> Router<Arc<Mutex<BotState>>> {
9+
let apikeys_router = Router::new()
10+
.route("/", post(create_api_key_handler))
11+
.route("/", get(list_api_keys_handler))
12+
.route("/{id}/revoke", post(revoke_api_key_handler))
13+
.route("/{id}", delete(delete_api_key_handler))
14+
.layer(axum::middleware::from_fn_with_state(
15+
bot_state,
16+
auth_middleware,
17+
));
18+
19+
apikeys_router
20+
}

rustmail/src/api/routes/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1+
pub mod apikeys;
12
pub mod auth;
23
pub mod bot;
34
pub mod externals;
45
pub mod panel;
56
pub mod user;
67

8+
pub use apikeys::*;
79
pub use auth::*;
810
pub use bot::*;
911
pub use externals::*;

0 commit comments

Comments
 (0)