Skip to content

Commit

Permalink
fix cargo fmt check
Browse files Browse the repository at this point in the history
  • Loading branch information
gerardcl committed Jan 9, 2024
1 parent 6cd6a08 commit 899ef11
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 20 deletions.
20 changes: 10 additions & 10 deletions be-rust-axum/rust-template/src/api/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ pub async fn serve(address: SocketAddr) {

info!("Server listening on {}", &address);
axum::serve(listener, app().into_make_service())
.with_graceful_shutdown(shutdown_signal())
.await
.with_graceful_shutdown(shutdown_signal())
.await
.expect("Failed to start server");
}

Expand All @@ -42,16 +42,16 @@ async fn fallback() -> (StatusCode, Json<Status>) {
/// Setup example of the OS signal handlers to catch for proper server graceful shutdown.
async fn shutdown_signal() {
let interrupt = async {
signal(SignalKind::interrupt())
.expect("failed to install signal handler")
.recv()
.await;
signal(SignalKind::interrupt())
.expect("failed to install signal handler")
.recv()
.await;
};
let terminate = async {
signal(SignalKind::terminate())
.expect("failed to install signal handler")
.recv()
.await;
signal(SignalKind::terminate())
.expect("failed to install signal handler")
.recv()
.await;
};
tokio::select! {
_ = interrupt => {},
Expand Down
18 changes: 9 additions & 9 deletions be-rust-axum/rust-template/src/config/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,24 @@ use tracing::Level;
lazy_static! {
/// The lazy loaded static Settings struct that calls `Settings::load()` when the app starts,
/// and that is used whenever a configuration attribute is required within the app.
pub static ref SETTINGS: Settings = Settings::load();
pub static ref SETTINGS: Settings = Settings::load();
}

/// The Settings struct where the required config for our app is loaded into
#[derive(Deserialize, Debug)]
pub struct Settings {
/// The server port to listen to - must be u16 (number).
///
/// Defaults to 8080
/// The server port to listen to - must be u16 (number).
///
/// Defaults to 8080
pub port: u16,
/// The server global log_level - must be either "TRACE", "DEBUG", "INFO", "WARN" or "ERROR".
///
/// Defaults to DEBUG
/// The server global log_level - must be either "TRACE", "DEBUG", "INFO", "WARN" or "ERROR".
///
/// Defaults to DEBUG
pub log_level: String,
}

impl Settings {
/// Creates/loads the `Settings` with the configuration parameters required for the app
/// Creates/loads the `Settings` with the configuration parameters required for the app
pub fn load() -> Self {
Settings {
port: std::env::var("PORT")
Expand All @@ -33,7 +33,7 @@ impl Settings {
}
}

/// Translates the `log_level` String to the proper `tracing::Level` value.
/// Translates the `log_level` String to the proper `tracing::Level` value.
pub fn log_level(&self) -> Level {
match self.log_level.as_str() {
"ERROR" => Level::ERROR,
Expand Down
2 changes: 1 addition & 1 deletion be-rust-axum/rust-template/src/models/status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ use serde::{Deserialize, Serialize};
/// The Status object used to inform about the health of the app
#[derive(Serialize, Deserialize, Debug)]
pub struct Status {
/// the `status` String - being for now always `Ok` if one can reach endpoint
/// the `status` String - being for now always `Ok` if one can reach endpoint
pub status: String,
}

0 comments on commit 899ef11

Please sign in to comment.