From e8954d40bc14078313032d895645dde3e38d0869 Mon Sep 17 00:00:00 2001 From: Joshua Higgins Date: Tue, 8 Apr 2025 19:40:11 -0400 Subject: [PATCH] Finished program --- .idea/.gitignore | 8 ++++++++ .idea/modules.xml | 8 ++++++++ .idea/status-checker.iml | 11 +++++++++++ .idea/vcs.xml | 6 ++++++ Cargo.toml | 7 +++++++ src/main.rs | 25 +++++++++++++++++++++++++ 6 files changed, 65 insertions(+) create mode 100644 .idea/.gitignore create mode 100644 .idea/modules.xml create mode 100644 .idea/status-checker.iml create mode 100644 .idea/vcs.xml create mode 100644 Cargo.toml create mode 100644 src/main.rs diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..0b7df34 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/status-checker.iml b/.idea/status-checker.iml new file mode 100644 index 0000000..cf84ae4 --- /dev/null +++ b/.idea/status-checker.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..80f1b43 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,7 @@ +[package] +name = "status-checker" +version = "0.1.0" +edition = "2021" + +[dependencies] +rocket = "0.5.1" diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..cbee9d9 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,25 @@ +use rocket::http::Status; +use rocket::*; +use std::process::Command; + +#[get("/")] +fn index() -> Status { + let result = Command::new("ping") + .args(["8.8.8.8", "-c", "1", "-W", "1"]) + .status(); + + match result { + Ok(stream) => { + match stream.success() { + true => Status::Ok, + false => Status::InternalServerError, + } + } + Err(_) => Status::InternalServerError, + } +} + +#[launch] +fn rocket() -> _ { + build().mount("/", routes![index]) +}