diff --git a/src/main.rs b/src/main.rs
index c1e9987..5e990f7 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,12 +1,10 @@
use axum::body::Body;
-use axum::extract::Path;
use axum::http::header::AUTHORIZATION;
use axum::http::{Request, StatusCode};
use axum::middleware::{from_fn, Next};
use axum::response::{IntoResponse, Response};
use axum::routing::{delete, post};
-use axum::{Extension, Json, Router};
-use bwhc_dto::MtbFile;
+use axum::{Extension, Router};
use clap::Parser;
use lazy_static::lazy_static;
use serde::{Deserialize, Serialize};
@@ -14,11 +12,13 @@ use serde::{Deserialize, Serialize};
use tower_http::trace::TraceLayer;
use crate::cli::Cli;
+use crate::routes::{handle_delete, handle_post};
use crate::sender::MtbFileSender;
use crate::AppResponse::{Accepted, InternalServerError, Unauthorized};
mod auth;
mod cli;
+mod routes;
mod sender;
#[derive(Serialize, Deserialize)]
@@ -94,28 +94,6 @@ async fn check_basic_auth(request: Request
, next: Next) -> Response {
Unauthorized.into_response()
}
-async fn handle_delete(
- Path(patient_id): Path,
- Extension(sender): Extension,
-) -> Response {
- let delete_mtb_file = MtbFile::new_with_consent_rejected(&patient_id);
-
- match sender.send(delete_mtb_file).await {
- Ok(request_id) => Accepted(&request_id).into_response(),
- _ => InternalServerError.into_response(),
- }
-}
-
-async fn handle_post(
- Extension(sender): Extension,
- Json(mtb_file): Json,
-) -> Response {
- match sender.send(mtb_file).await {
- Ok(request_id) => Accepted(&request_id).into_response(),
- _ => InternalServerError.into_response(),
- }
-}
-
#[cfg(test)]
mod tests {
use axum::http::StatusCode;
diff --git a/src/routes.rs b/src/routes.rs
new file mode 100644
index 0000000..8d80869
--- /dev/null
+++ b/src/routes.rs
@@ -0,0 +1,28 @@
+use crate::sender::MtbFileSender;
+use crate::AppResponse::{Accepted, InternalServerError};
+use axum::extract::Path;
+use axum::response::{IntoResponse, Response};
+use axum::{Extension, Json};
+use bwhc_dto::MtbFile;
+
+pub async fn handle_delete(
+ Path(patient_id): Path,
+ Extension(sender): Extension,
+) -> Response {
+ let delete_mtb_file = MtbFile::new_with_consent_rejected(&patient_id);
+
+ match sender.send(delete_mtb_file).await {
+ Ok(request_id) => Accepted(&request_id).into_response(),
+ _ => InternalServerError.into_response(),
+ }
+}
+
+pub async fn handle_post(
+ Extension(sender): Extension,
+ Json(mtb_file): Json,
+) -> Response {
+ match sender.send(mtb_file).await {
+ Ok(request_id) => Accepted(&request_id).into_response(),
+ _ => InternalServerError.into_response(),
+ }
+}