diff --git a/services/blob/src/http/mod.rs b/services/blob/src/http/mod.rs new file mode 100644 --- /dev/null +++ b/services/blob/src/http/mod.rs @@ -0,0 +1,33 @@ +use crate::config::CONFIG; +use crate::database::DatabaseClient; +use crate::s3::S3Client; + +use actix_web::{web, App, HttpServer}; +use anyhow::Result; +use tracing::info; + +async fn hello_handler() -> impl actix_web::Responder { + "Hello, world!" +} + +// disable unused warning for now +#[allow(unused)] +pub async fn run_http_server( + db_client: DatabaseClient, + s3_client: S3Client, +) -> Result<()> { + info!( + "Starting HTTP server listening at port {}", + CONFIG.http_port + ); + HttpServer::new(move || { + App::new() + .wrap(tracing_actix_web::TracingLogger::default()) + .service(web::resource("/hello").route(web::get().to(hello_handler))) + }) + .bind(("0.0.0.0", CONFIG.http_port))? + .run() + .await?; + + Ok(()) +} diff --git a/services/blob/src/main.rs b/services/blob/src/main.rs --- a/services/blob/src/main.rs +++ b/services/blob/src/main.rs @@ -2,6 +2,7 @@ pub mod constants; pub mod database; pub mod grpc; +pub mod http; pub mod s3; pub mod tools; @@ -28,5 +29,8 @@ let db = database::DatabaseClient::new(&aws_config); let s3 = s3::S3Client::new(&aws_config); - crate::grpc::run_grpc_server(db, s3).await + tokio::select! { + http_result = crate::http::run_http_server(db.clone(), s3.clone()) => http_result, + grpc_result = crate::grpc::run_grpc_server(db, s3) => grpc_result, + } }