Compare commits

..

No commits in common. "df42a755f78bdf628b15759ff319cc11c1537c26" and "5b1f43777365eb9e7054ce072127edeaccf744b3" have entirely different histories.

2 changed files with 4 additions and 23 deletions

View File

@ -4,8 +4,7 @@ Example `config.extension` file to be created in `etc` sub-directory of working
```yaml
---
bind: <Optional, bind/interface to listen requests on. By default localhost only>
port: <Optional port, start service on 7777 by default>
port: 8356
apps:
example-website.tld/optional_domain_path:
AUTH_TOKEN: <a super secret token sent in request>

View File

@ -1,7 +1,7 @@
/*
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 log::{debug, error, info, warn};
use serde::Deserialize;
@ -56,23 +56,10 @@ impl AppConfig {
#[derive(Debug, Deserialize)]
struct Settings {
#[serde(default = "Settings::default_bind_localhost")]
bind: String,
#[serde(default = "Settings::default_port")]
port: u16,
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)]
struct QueryParams {
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")]
async fn deploy(
request: HttpRequest,
@ -359,8 +341,8 @@ async fn main() -> std::io::Result<()> {
APPS_CONFIG.get_or_init(|| settings.apps);
APPS_DEPLOYMENT_LOCK.get_or_init(|| RwLock::new(HashSet::new()));
HttpServer::new(|| App::new().service(deploy).service(ping))
.bind((settings.bind.as_str(), settings.port))?
HttpServer::new(|| App::new().service(deploy))
.bind(("127.0.0.1", settings.port))?
.run()
.await
}