Function ntex::web::server[][src]

pub fn server<F, I, S, B>(factory: F) -> HttpServer<F, I, S, B> where
    F: Fn() -> I + Send + Clone + 'static,
    I: IntoServiceFactory<S, Request, AppConfig>,
    S: ServiceFactory<Request, AppConfig> + 'static,
    S::Error: ResponseError,
    S::InitError: Debug,
    S::Response: Into<Response<B>>,
    B: MessageBody + 'static, 
Expand description

Create new http server with application factory.

use ntex::web;

#[ntex::main]
async fn main() -> std::io::Result<()> {
    web::server(
        || web::App::new()
            .service(web::resource("/").to(|| async { web::HttpResponse::Ok() })))
        .bind("127.0.0.1:59090")?
        .run()
        .await
}