Skip to content

Commit

Permalink
fix: Reintroduce car_mirror_axum::serve
Browse files Browse the repository at this point in the history
  • Loading branch information
matheus23 committed Mar 1, 2024
1 parent b4da6ac commit 66bc2d6
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions car-mirror-axum/src/server.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::{extract::dag_cbor::DagCbor, AppResult};
use anyhow::Result;
use axum::{
body::{Body, HttpBody},
extract::{Path, State},
Expand All @@ -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()
Expand Down

0 comments on commit 66bc2d6

Please sign in to comment.