Created
October 18, 2020 05:31
-
-
Save LironHazan/2c1866f23ca5cccb7dd64bed1027d5d9 to your computer and use it in GitHub Desktop.
snippet 4 for post
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use crate::server::routes::AppState; | |
use crate::server; | |
use actix_web::dev::Server; | |
use actix_web::{App, HttpServer}; | |
// Starts the server with wanted configuration and shared state | |
async fn start_server(results_count: usize, server_address: &str) -> Result<Server, std::io::Error> { | |
let server = HttpServer::new(move || { | |
App::new().data(AppState { | |
results_count, | |
}).configure(server::routes::init_routes)}) | |
.bind(server_address)? | |
.run(); | |
Ok(server) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment