Added get method for testing and monitoring

This commit is contained in:
Manish 2025-06-19 11:09:38 +10:00
parent 5c78958ec7
commit 11131cf16a
2 changed files with 9 additions and 3 deletions

View File

@ -4,7 +4,8 @@ Example `config.extension` file to be created in `etc` sub-directory of working
```yaml
---
port: 8356
bind: <Optional, bind/interface to listen requests on. By default localhost only>
port: <Optional port, start service on 7777 by default>
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, post, web};
use actix_web::{App, HttpRequest, HttpResponse, HttpServer, Responder, Result, get, post, web};
use config::Config;
use log::{debug, error, info, warn};
use serde::Deserialize;
@ -140,6 +140,11 @@ fn release_deployment_lock(request_id: &str, app_name: &str) {
}
}
#[get("/deploy")]
async fn ping() -> impl Responder {
"\\\\m//"
}
#[post("/deploy")]
async fn deploy(
request: HttpRequest,
@ -354,7 +359,7 @@ 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))
HttpServer::new(|| App::new().service(deploy).service(ping))
.bind((settings.bind.as_str(), settings.port))?
.run()
.await