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()