1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
use crate::{service::manager::PulseManager, utils::check_auth::check_auth};
use actix_web::{
    get,
    web::{Data, Path},
    HttpResponse, Responder, Result,
};
use actix_web_httpauth::extractors::basic::BasicAuth;
use std::sync::Arc;

#[doc(hidden)]
#[get("/status/{id}")]
pub async fn status(
    id: Path<String>,
    manager: Data<Arc<PulseManager>>,
    auth: Option<BasicAuth>,
) -> Result<impl Responder> {
    if !check_auth(&auth, &manager.settings) {
        return Ok(HttpResponse::Unauthorized().body("Unauthorized"));
    }

    let scan_ev = manager.get_event(&id);

    Ok(HttpResponse::Ok().json(scan_ev))
}