Compare commits
	
		
			No commits in common. "df42a755f78bdf628b15759ff319cc11c1537c26" and "5b1f43777365eb9e7054ce072127edeaccf744b3" have entirely different histories.
		
	
	
		
			df42a755f7
			...
			5b1f437773
		
	
		
@ -4,8 +4,7 @@ Example `config.extension` file to be created in `etc` sub-directory of working
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
```yaml
 | 
					```yaml
 | 
				
			||||||
---
 | 
					---
 | 
				
			||||||
bind: <Optional, bind/interface to listen requests on. By default localhost only>
 | 
					port: 8356
 | 
				
			||||||
port: <Optional port, start service on 7777 by default>
 | 
					 | 
				
			||||||
apps:
 | 
					apps:
 | 
				
			||||||
  example-website.tld/optional_domain_path:
 | 
					  example-website.tld/optional_domain_path:
 | 
				
			||||||
    AUTH_TOKEN: <a super secret token sent in request>
 | 
					    AUTH_TOKEN: <a super secret token sent in request>
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										24
									
								
								src/main.rs
									
									
									
									
									
								
							
							
						
						
									
										24
									
								
								src/main.rs
									
									
									
									
									
								
							@ -1,7 +1,7 @@
 | 
				
			|||||||
/*
 | 
					/*
 | 
				
			||||||
Run as `RUST_LOG=debug ./deployment-api-rs`
 | 
					Run as `RUST_LOG=debug ./deployment-api-rs`
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
use actix_web::{App, HttpRequest, HttpResponse, HttpServer, Responder, Result, get, post, web};
 | 
					use actix_web::{App, HttpRequest, HttpResponse, HttpServer, Responder, Result, post, web};
 | 
				
			||||||
use config::Config;
 | 
					use config::Config;
 | 
				
			||||||
use log::{debug, error, info, warn};
 | 
					use log::{debug, error, info, warn};
 | 
				
			||||||
use serde::Deserialize;
 | 
					use serde::Deserialize;
 | 
				
			||||||
@ -56,23 +56,10 @@ impl AppConfig {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#[derive(Debug, Deserialize)]
 | 
					#[derive(Debug, Deserialize)]
 | 
				
			||||||
struct Settings {
 | 
					struct Settings {
 | 
				
			||||||
    #[serde(default = "Settings::default_bind_localhost")]
 | 
					 | 
				
			||||||
    bind: String,
 | 
					 | 
				
			||||||
    #[serde(default = "Settings::default_port")]
 | 
					 | 
				
			||||||
    port: u16,
 | 
					    port: u16,
 | 
				
			||||||
    apps: HashMap<String, AppConfig>,
 | 
					    apps: HashMap<String, AppConfig>,
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
impl Settings {
 | 
					 | 
				
			||||||
    fn default_port() -> u16 {
 | 
					 | 
				
			||||||
        7777
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    fn default_bind_localhost() -> String {
 | 
					 | 
				
			||||||
        String::from("127.0.0.1")
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#[derive(Debug, Deserialize)]
 | 
					#[derive(Debug, Deserialize)]
 | 
				
			||||||
struct QueryParams {
 | 
					struct QueryParams {
 | 
				
			||||||
    auth_token: String,
 | 
					    auth_token: String,
 | 
				
			||||||
@ -140,11 +127,6 @@ fn release_deployment_lock(request_id: &str, app_name: &str) {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#[get("/ping")]
 | 
					 | 
				
			||||||
async fn ping() -> impl Responder {
 | 
					 | 
				
			||||||
    "\\\\m//"
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#[post("/deploy")]
 | 
					#[post("/deploy")]
 | 
				
			||||||
async fn deploy(
 | 
					async fn deploy(
 | 
				
			||||||
    request: HttpRequest,
 | 
					    request: HttpRequest,
 | 
				
			||||||
@ -359,8 +341,8 @@ async fn main() -> std::io::Result<()> {
 | 
				
			|||||||
    APPS_CONFIG.get_or_init(|| settings.apps);
 | 
					    APPS_CONFIG.get_or_init(|| settings.apps);
 | 
				
			||||||
    APPS_DEPLOYMENT_LOCK.get_or_init(|| RwLock::new(HashSet::new()));
 | 
					    APPS_DEPLOYMENT_LOCK.get_or_init(|| RwLock::new(HashSet::new()));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    HttpServer::new(|| App::new().service(deploy).service(ping))
 | 
					    HttpServer::new(|| App::new().service(deploy))
 | 
				
			||||||
        .bind((settings.bind.as_str(), settings.port))?
 | 
					        .bind(("127.0.0.1", settings.port))?
 | 
				
			||||||
        .run()
 | 
					        .run()
 | 
				
			||||||
        .await
 | 
					        .await
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user