-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Christina Sørensen <[email protected]>
- Loading branch information
Showing
7 changed files
with
55 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,5 @@ | |
// SPDX-License-Identifier: AGPL-3.0-only | ||
|
||
pub mod routes; | ||
|
||
mod status; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// SPDX-FileCopyrightText: 2024 Christina Sørensen | ||
// SPDX-FileContributor: Christina Sørensen | ||
// | ||
// SPDX-License-Identifier: AGPL-3.0-only | ||
|
||
use crate::data::status::{Status, ServerState}; | ||
use axum::{Json, http::StatusCode}; | ||
|
||
const TEST_STATUS: Status = Status { server_state: ServerState::Healthy }; | ||
|
||
/// Handler for returning the server status. | ||
pub async fn status() -> Result<Json<Status>, StatusCode> { | ||
Ok(Json(TEST_STATUS)) | ||
} | ||
// pub async fn status() -> StatusCode { | ||
// StatusCode::OK | ||
// } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pub mod handlers; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,10 @@ | ||
// SPDX-FileCopyrightText: 2023 Christina Sørensen | ||
// SPDX-FileCopyrightText: 2024 Christina Sørensen | ||
// SPDX-FileContributor: Christina Sørensen | ||
// | ||
// SPDX-License-Identifier: AGPL-3.0-only | ||
|
||
pub mod status; | ||
|
||
mod config; | ||
|
||
pub use self::config::{Config, CONFIG}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// SPDX-FileCopyrightText: 2024 Christina Sørensen | ||
// SPDX-FileContributor: Christina Sørensen | ||
// | ||
// SPDX-License-Identifier: AGPL-3.0-only | ||
|
||
use serde::{Deserialize, Serialize}; | ||
|
||
/// The state of the server. | ||
/// | ||
/// - Healthy: everything is working | ||
/// - Degraded: something is broken, but ha-registry can still run | ||
/// - Unhealthy: ha-registry is not working | ||
/// | ||
/// May be expanded later. | ||
#[derive(Serialize, Deserialize)] | ||
pub enum ServerState { | ||
Healthy, | ||
Degraded, | ||
Unhealthy, | ||
} | ||
|
||
/// Status struct exposed over status endpoint. Used to see the current state of | ||
/// ha-registry. | ||
#[derive(Serialize, Deserialize)] | ||
pub struct Status { | ||
pub server_state: ServerState, | ||
} |