diff --git a/crates/collab/src/api.rs b/crates/collab/src/api.rs index 6cdd28044c..cea51ce2aa 100644 --- a/crates/collab/src/api.rs +++ b/crates/collab/src/api.rs @@ -28,6 +28,7 @@ pub fn routes(state: Arc) -> Router { .layer(Extension(state)) .layer(middleware::from_fn(validate_api_token)), ) + // TODO: Compression on API routes? } pub async fn validate_api_token(req: Request, next: Next) -> impl IntoResponse { diff --git a/crates/collab/src/main.rs b/crates/collab/src/main.rs index 5fea3699e9..b19cae1959 100644 --- a/crates/collab/src/main.rs +++ b/crates/collab/src/main.rs @@ -51,28 +51,13 @@ async fn main() -> Result<()> { let config = envy::from_env::().expect("error loading config"); let state = AppState::new(&config).await?; - let rpc = Peer::new(); - run_server( - state.clone(), - rpc, - TcpListener::bind(&format!("0.0.0.0:{}", config.http_port)) - .expect("failed to bind TCP listener"), - ) - .await?; - Ok(()) -} -pub async fn run_server( - state: Arc, - peer: Arc, - listener: TcpListener, -) -> Result<()> { - // TODO: Compression on API routes? - // TODO: Authenticate API routes. + let listener = TcpListener::bind(&format!("0.0.0.0:{}", config.http_port)) + .expect("failed to bind TCP listener"); - let app = Router::::new().merge(api::routes(state.clone())); - - // TODO: Add rpc routes + let app = Router::::new() + .merge(api::routes(state)) + .merge(rpc::routes(Peer::new())); axum::Server::from_tcp(listener)? .serve(app.into_make_service()) diff --git a/crates/collab/src/rpc.rs b/crates/collab/src/rpc.rs index 1cc163d633..cbde3adcbb 100644 --- a/crates/collab/src/rpc.rs +++ b/crates/collab/src/rpc.rs @@ -1099,6 +1099,10 @@ // } // } +pub fn routes(peer: Arc) -> Router { + Router::new() +} + // pub fn add_routes(app: &mut tide::Server>, rpc: &Arc) { // let server = Server::new(app.state().clone(), rpc.clone(), None); // app.at("/rpc").get(move |request: Request>| { @@ -6360,3 +6364,6 @@ // } // } // } + +use axum::{body::Body, Router}; +use client::Peer;