pub fn init_web_server(scheduler: Addr<Scheduler>, settings: Settings) {
    let settings_for_app = settings.clone();
    let server = HttpServer::new(move || {
        App::new()
            .data(AppState {
                scheduler: scheduler.clone(),
                settings: settings_for_app.clone(),
            })
            .service(web::resource("/{webhook_name}").to(webhook))
            .service(web::resource("/").to(index))
    });

    let address = format!("{}:{}", settings.domain, settings.port);

    // Load the ssl key, if something is specified in the settings
    if settings.ssl_cert_chain.is_some() && settings.ssl_private_key.is_some() {
        let builder = get_ssl_builder(&settings);
        server.bind_ssl(address, builder).unwrap().start();
    } else {
        server.bind(address).unwrap().start();
    }
}
/// Initialize the web server
/// Move the address of the queue actor inside the AppState for further dispatch
/// of tasks to the actor
Initialize the web server
Move the address of the queue actor inside the AppState for further dispatch
of tasks to the actor
Initialize the web server Move the address of the queue actor inside the AppState for further dispatch of tasks to the actor
pub fn init_web_server(scheduler: Addr<Scheduler>, settings: Settings) {
    let settings_for_app = settings.clone();
    let server = HttpServer::new(move || {
        App::new()
            .data(AppState {
                scheduler: scheduler.clone(),
                settings: settings_for_app.clone(),
            })
            .service(web::resource("/{webhook_name}").to(webhook))
            .service(web::resource("/").to(index))
    });
    let address = format!("{}:{}", settings.domain, settings.port);
    // Load the ssl key, if something is specified in the settings
    if settings.ssl_cert_chain.is_some() && settings.ssl_private_key.is_some() {
        let builder = get_ssl_builder(&settings);
        server.bind_ssl(address, builder).unwrap().start();
    } else {
        server.bind(address).unwrap().start();
    }
}
pub fn init_web_server ( scheduler : Addr < Scheduler > , settings : Settings ) { let settings_for_app = settings . clone ( ) ; let server = HttpServer :: new ( move | | { App :: new ( ) . data ( AppState { scheduler : scheduler . clone ( ) , settings : settings_for_app . clone ( ) , } ) . service ( web :: resource ( " " ) . to ( webhook ) ) . service ( web :: resource ( " " ) . to ( index ) ) } ) ; let address = format ! ( " " settings domain settings port ) ; // Load the ssl key, if something is specified in the settings if settings . ssl_cert_chain . is_some ( ) && settings . ssl_private_key . is_some ( ) { let builder = get_ssl_builder ( & settings ) ; server . bind_ssl ( address , builder ) . unwrap ( ) . start ( ) ; } else { server . bind ( address ) . unwrap ( ) . start ( ) ; } }
Initialize the web server
Move the address of the queue actor inside the AppState for further dispatch
of tasks to the actor
Initialize the web server Move the address of the queue actor inside the AppState for further dispatch of tasks to the actor
scheduler
Addr<Scheduler>
settings
Settings
scheduler
Addr<Scheduler>
settings
Settings