diff options
author | niliara-edu <nil.jimeno@estudiant.fjaverianas.com> | 2024-09-27 14:04:23 +0200 |
---|---|---|
committer | niliara-edu <nil.jimeno@estudiant.fjaverianas.com> | 2024-09-27 14:04:23 +0200 |
commit | db58cb58b5d5612ec2aa347d0f8531b26ab2e7f3 (patch) | |
tree | 948e96bf2eabc7694194c07e9ac19acafa760b94 /rust/src | |
parent | 9d70bfed33df8ea4cd77f915454da265edccf401 (diff) |
upload changes
Diffstat (limited to 'rust/src')
-rw-r--r-- | rust/src/main.rs | 4 | ||||
-rw-r--r-- | rust/src/routes.rs | 1 | ||||
-rw-r--r-- | rust/src/routes/hello.rs | 11 |
3 files changed, 14 insertions, 2 deletions
diff --git a/rust/src/main.rs b/rust/src/main.rs index 2ccdcee..af45779 100644 --- a/rust/src/main.rs +++ b/rust/src/main.rs @@ -1,4 +1,5 @@ mod structs; +mod routes; use actix_web::{web, App, HttpServer}; use sqlx::mysql::{MySqlPool, MySqlPoolOptions}; @@ -10,8 +11,6 @@ struct AppState { #[actix_web::main] async fn main() -> std::io::Result<()> { - const DB_URL: &str = "mysql://root:@127.0.0.1:3306/balalaika"; - let pool: MySqlPool = MySqlPoolOptions::new() .max_connections(10) .connect(DB_URL) @@ -24,6 +23,7 @@ async fn main() -> std::io::Result<()> { App::new() .app_data(web::Data::new(app_state.clone())) .route("/", web::get().to(root)) + .service(routes::hello::hello_actix) }) .bind(("127.0.0.1", 8000))? .run() diff --git a/rust/src/routes.rs b/rust/src/routes.rs new file mode 100644 index 0000000..8cb6ff0 --- /dev/null +++ b/rust/src/routes.rs @@ -0,0 +1 @@ +mod hello; diff --git a/rust/src/routes/hello.rs b/rust/src/routes/hello.rs new file mode 100644 index 0000000..c356081 --- /dev/null +++ b/rust/src/routes/hello.rs @@ -0,0 +1,11 @@ +use crate::AppState; +use actix_web::{get, web, HttpResponse}; +use serde::Deserialize; + +#[get("/hello")] +pub async fn hello_actix(app_state: web::Data<AppState>) -> HttpResponse { + struct Song { + } + + return HttpResponse::Ok().json(databases); +} |