pub fn serve(mut args: Args) -> Result<(), Error> {
    let tera_pattern_os = args.templates.join("*.html").into_os_string();
    let tera_pattern = tera_pattern_os.to_string_lossy();
    let mut tera = Tera::new(&tera_pattern).map_err(TeraFailure::from)?;
    register_tera_filters(&mut tera);

    let mut core = Core::new()?;
    let handle = core.handle();

    let mut builder = Client::builder();
    if let Some(proxy) = args.proxy.take() {
        builder = builder.proxy(Proxy::all(proxy)?);
    }
    let mut default_headers = HeaderMap::new();
    default_headers.insert(CONNECTION, HeaderValue::from_str("Close").unwrap());
    let client = builder
        .timeout(Duration::from_secs(120))
        .default_headers(default_headers)
        .build()?;

    let address = args.address;
    let handler = Rc::new(Handler {
        tera: Rc::new(RefCell::new(tera)),
        client,
        args: Rc::new(args),
    });

    let serve =
        Http::new().serve_addr_handle(&address, &handle, move || Ok(Rc::clone(&handler)))?;

    let conn_handle = handle.clone();
    handle.spawn(
        serve
            .for_each(move |conn| {
                conn_handle.spawn(conn.map(|_| ()).map_err(|e| debug!("server error: {}", e)));
                Ok(())
            })
            .map_err(|_| ()),
    );

    core.run(empty::<(), Error>())?;
    Ok(())
}
/// Serves the borsholder web page configured according to `args`.
///
/// This method will not return until the server is shutdown.
Serves the borsholder web page configured according to `args`.
This method will not return until the server is shutdown.
Serves the borsholder web page configured according to ` args ` . This method will not return until the server is shutdown .
pub fn serve(mut args: Args) -> Result<(), Error> {
    let tera_pattern_os = args.templates.join("*.html").into_os_string();
    let tera_pattern = tera_pattern_os.to_string_lossy();
    let mut tera = Tera::new(&tera_pattern).map_err(TeraFailure::from)?;
    register_tera_filters(&mut tera);
    let mut core = Core::new()?;
    let handle = core.handle();
    let mut builder = Client::builder();
    if let Some(proxy) = args.proxy.take() {
        builder = builder.proxy(Proxy::all(proxy)?);
    }
    let mut default_headers = HeaderMap::new();
    default_headers.insert(CONNECTION, HeaderValue::from_str("Close").unwrap());
    let client = builder
        .timeout(Duration::from_secs(120))
        .default_headers(default_headers)
        .build()?;
    let address = args.address;
    let handler = Rc::new(Handler {
        tera: Rc::new(RefCell::new(tera)),
        client,
        args: Rc::new(args),
    });
    let serve =
        Http::new().serve_addr_handle(&address, &handle, move || Ok(Rc::clone(&handler)))?;
    let conn_handle = handle.clone();
    handle.spawn(
        serve
            .for_each(move |conn| {
                conn_handle.spawn(conn.map(|_| ()).map_err(|e| debug!("server error: {}", e)));
                Ok(())
            })
            .map_err(|_| ()),
    );
    core.run(empty::<(), Error>())?;
    Ok(())
}
pub fn serve ( mut args : Args ) -> Result < ( ) , Error > { let tera_pattern_os = args . templates . join ( " " ) . into_os_string ( ) ; let tera_pattern = tera_pattern_os . to_string_lossy ( ) ; let mut tera = Tera :: new ( & tera_pattern ) . map_err ( TeraFailure :: from ) ? ; register_tera_filters ( & mut tera ) ; let mut core = Core :: new ( ) ? ; let handle = core . handle ( ) ; let mut builder = Client :: builder ( ) ; if let Some ( proxy ) = args . proxy . take ( ) { builder = builder . proxy ( Proxy :: all ( proxy ) ? ) ; } let mut default_headers = HeaderMap :: new ( ) ; default_headers . insert ( CONNECTION , HeaderValue :: from_str ( " " ) . unwrap ( ) ) ; let client = builder . timeout ( Duration :: from_secs ( 120 ) ) . default_headers ( default_headers ) . build ( ) ? ; let address = args . address ; let handler = Rc :: new ( Handler { tera : Rc :: new ( RefCell :: new ( tera ) ) , client , args : Rc :: new ( args ) , } ) ; let serve = Http :: new ( ) . serve_addr_handle ( & address , & handle , move | | Ok ( Rc :: clone ( & handler ) ) ) ? ; let conn_handle = handle . clone ( ) ; handle . spawn ( serve . for_each ( move | conn | { conn_handle . spawn ( conn . map ( | _ | ( ) ) . map_err ( | e | debug ! ( " " e ) ) ) ; Ok ( ( ) ) } ) . map_err ( | _ | ( ) ) , ) ; core . run ( empty :: < ( ) , Error > ( ) ) ? ; Ok ( ( ) ) }
Serves the borsholder web page configured according to `args`.
Serves the borsholder web page configured according to ` args ` .
args
Args
args
Args