pub fn server<F, I, Sf>(factory: F) -> HttpServer<NoConfig, F, I, Sf>where
F: AsyncFn(&()) -> I + Send + Clone + 'static,
I: IntoServiceFactory<Sf, (), Request>,
Sf: ServiceFactory<(), Request> + 'static,
Sf::Res: Into<Response>,
Sf::Error: ResponseError,
Sf::InitError: IntoFailure,Expand description
Create new http server with application factory.
use ntex::{web, SharedCfg};
#[ntex::main]
async fn main() -> std::io::Result<()> {
web::server(async |_| {
web::App::new()
.service(web::resource("/").to(async || { web::HttpResponse::Ok() }))
})
.bind("127.0.0.1:59090", SharedCfg::default())?
.run()
.await
}