Implemented user specifieable host and port
This commit is contained in:
		
							parent
							
								
									46e3eea247
								
							
						
					
					
						commit
						bd7dce7981
					
				| 
						 | 
				
			
			@ -10,7 +10,7 @@ async fn main() -> std::io::Result<()> {
 | 
			
		|||
    logger::init_logger(&cli);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    if let Err(e) = public::start_actix().await {
 | 
			
		||||
    if let Err(e) = public::start_actix(&cli).await {
 | 
			
		||||
        log::error!("Actix had an error: {e}");
 | 
			
		||||
    }
 | 
			
		||||
    Ok(())
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,14 +4,18 @@ mod templates;
 | 
			
		|||
 | 
			
		||||
use actix_web::{web, App, HttpServer};
 | 
			
		||||
 | 
			
		||||
pub(crate) async fn start_actix() -> anyhow::Result<()> {
 | 
			
		||||
    log::info!("Serving an http server at http://0.0.0.0:8080");
 | 
			
		||||
use crate::cli::CliArgs;
 | 
			
		||||
 | 
			
		||||
pub(crate) async fn start_actix(cli: &CliArgs) -> anyhow::Result<()> {
 | 
			
		||||
    let bindip = format!("{}:{}", cli.host, cli.port);
 | 
			
		||||
 | 
			
		||||
    log::info!("Serving an http server at http://{bindip}");
 | 
			
		||||
    HttpServer::new(|| {
 | 
			
		||||
        App::new()
 | 
			
		||||
            .route("/", web::get().to(routes::index))
 | 
			
		||||
    })
 | 
			
		||||
 | 
			
		||||
    .bind("0.0.0.0:8080")?
 | 
			
		||||
    .bind(bindip)?
 | 
			
		||||
    .run()
 | 
			
		||||
    .await?;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue
	
	Block a user