From 69c688e574faa908a201a69d4ed9f2a02c64d926 Mon Sep 17 00:00:00 2001 From: znpra Date: Sun, 6 Aug 2023 09:42:38 -0400 Subject: [PATCH] keeping urls consistend with old backend --- src/main.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main.rs b/src/main.rs index b76c68f..c737a06 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,4 @@ -use std::env; +use std::{env, net::{IpAddr, SocketAddr}}; use axum::{ routing::get, @@ -11,6 +11,7 @@ use sqlx::{SqlitePool, sqlite::SqlitePoolOptions}; #[tokio::main] async fn main() { + let port = env::var("TTC_PORT").unwrap_or("3000".into()).parse().unwrap(); let pool = SqlitePoolOptions::new() .max_connections(5) .connect(env::var("TTC_DATABASE_URL") @@ -22,11 +23,11 @@ async fn main() { sqlx::migrate!("./migrations").run(&pool).await.unwrap(); let app = Router::new() - .route("/api/ttc/hello", get(|| async { "hello world!" })) - .route("/api/ttc/pronouns/:user", get(user_pronouns)) + .route("/api/the_third_can/hello", get(|| async { "hello world!" })) + .route("/api/the_third_can/pronouns/:user", get(user_pronouns)) .with_state(pool); - axum::Server::bind(&"0.0.0.0:3000".parse().unwrap()) + axum::Server::bind(&SocketAddr::new(IpAddr::from([0;4]), port)) .serve(app.into_make_service()) .await .unwrap();