Update versions

This commit is contained in:
LeNei
2024-02-03 22:26:44 +01:00
parent cc4d0d7ba1
commit f1b2f9b5d3
4 changed files with 252 additions and 196 deletions

View File

@@ -22,7 +22,7 @@ pub fn build_routes(api_context: ApiContext) -> Router {
// allow requests from any origin
.allow_origin(Any);
Router::new()
.route("/ping", get(ping))
.route("/", get(ping))
.layer(TraceLayer::new_for_http())
.layer(cors)
.with_state(api_context)

View File

@@ -2,7 +2,7 @@ use crate::config::Settings;
use crate::routes::{build_routes, ApiContext};
use anyhow::Context;
use axum::Router;
use std::net::TcpListener;
use tokio::net::TcpListener;
pub async fn build(settings: Settings) -> anyhow::Result<()> {
let api_context = ApiContext {
@@ -13,13 +13,13 @@ pub async fn build(settings: Settings) -> anyhow::Result<()> {
"{}:{}",
settings.application.host, settings.application.port
);
let listener = TcpListener::bind(address).context("Failed to bind to port")?;
let listener = TcpListener::bind(address).await.context("Failed to bind to port")?;
run(api_router, listener).await
}
async fn run(router: Router, listener: TcpListener) -> anyhow::Result<()> {
axum::Server::from_tcp(listener)?
.serve(router.into_make_service())
axum::serve(listener, router)
.await
.context("Failed to start server")
}