web/src/relay.rs

22 lines
653 B
Rust
Raw Normal View History

use actix_web::{HttpResponse, web, get};
use actix_web::http::StatusCode;
#[get("/gatus")]
pub async fn get_gatus_services() -> HttpResponse {
let status_response = if let Ok(res) = reqwest::get("https://s.ixvd.net/api/v1/endpoints/statuses").await {
res
} else {
return HttpResponse::build(StatusCode::INTERNAL_SERVER_ERROR)
.body("Failed to get status from gatus");
};
HttpResponse::build(StatusCode::OK)
.body(status_response.text().await.unwrap())
}
pub fn configure(cfg: &mut web::ServiceConfig) {
cfg.service(
web::scope("/relay")
.service(get_gatus_services)
);
}