From 66bc2d63a161cd48163fb915e9c2fe910db23347 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20Kr=C3=BCger?= Date: Fri, 1 Mar 2024 19:23:06 +0100 Subject: [PATCH] fix: Reintroduce `car_mirror_axum::serve` --- car-mirror-axum/src/server.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/car-mirror-axum/src/server.rs b/car-mirror-axum/src/server.rs index 304920f..3440685 100644 --- a/car-mirror-axum/src/server.rs +++ b/car-mirror-axum/src/server.rs @@ -1,4 +1,5 @@ use crate::{extract::dag_cbor::DagCbor, AppResult}; +use anyhow::Result; use axum::{ body::{Body, HttpBody}, extract::{Path, State}, @@ -21,6 +22,15 @@ use tower_http::{ }; use wnfs_common::BlockStore; +/// TODO(matheus23): docs +pub async fn serve(store: impl BlockStore + Clone + 'static) -> Result<()> { + let listener = tokio::net::TcpListener::bind("0.0.0.0:3344").await?; + let addr = listener.local_addr()?; + println!("Listening on {addr}"); + axum::serve(listener, app(store)).await?; + Ok(()) +} + /// TODO(matheus23): docs pub fn app(store: impl BlockStore + Clone + 'static) -> Router { let cors = CorsLayer::new()