use a trait object for the server, for dynamic dispatch

This commit is contained in:
Dustin J. Mitchell
2020-11-26 10:52:28 -05:00
parent 087333a227
commit a5c06008b3
5 changed files with 36 additions and 15 deletions

View File

@@ -1,5 +1,4 @@
use actix_web::{App, HttpServer};
use server::SyncServer;
use std::sync::Arc;
mod api;
@@ -10,11 +9,11 @@ mod types;
#[actix_web::main]
async fn main() -> std::io::Result<()> {
let sync_server = Arc::new(SyncServer::new());
let server_state = Arc::new(Box::new(server::NullSyncServer::new()));
HttpServer::new(move || {
App::new()
.data(sync_server.clone())
.data(server_state.clone())
.service(api::get_child_version::service)
.service(api::add_version::service)
})