Fix clippy lint errors
Some checks failed
Push Workflows / test (push) Successful in 1m33s
Push Workflows / docs (push) Successful in 1m45s
Push Workflows / clippy (push) Failing after 2m25s
Push Workflows / build (push) Successful in 4m0s
Push Workflows / leptos-test (push) Successful in 6m33s
Push Workflows / docker-build (push) Successful in 7m44s
Push Workflows / nix-build (push) Successful in 19m55s
Some checks failed
Push Workflows / test (push) Successful in 1m33s
Push Workflows / docs (push) Successful in 1m45s
Push Workflows / clippy (push) Failing after 2m25s
Push Workflows / build (push) Successful in 4m0s
Push Workflows / leptos-test (push) Successful in 6m33s
Push Workflows / docker-build (push) Successful in 7m44s
Push Workflows / nix-build (push) Successful in 19m55s
This commit is contained in:
@ -28,10 +28,10 @@ lazy_static! {
|
||||
|
||||
/// Initialize the database pool
|
||||
///
|
||||
/// Uses DATABASE_URL environment variable to connect to the database if set,
|
||||
/// Uses `DATABASE_URL` environment variable to connect to the database if set,
|
||||
/// otherwise builds a connection string from other environment variables.
|
||||
///
|
||||
/// Will panic if either the DATABASE_URL or POSTGRES_HOST environment variables
|
||||
/// Will panic if either the `DATABASE_URL` or `POSTGRES_HOST` environment variables
|
||||
/// are not set, or if there is an error creating the pool.
|
||||
///
|
||||
/// # Returns
|
||||
@ -48,14 +48,14 @@ fn init_db_pool() -> PgPool {
|
||||
log_url.push_str(&user);
|
||||
|
||||
if let Ok(password) = env::var("POSTGRES_PASSWORD") {
|
||||
url.push_str(":");
|
||||
log_url.push_str(":");
|
||||
url.push(':');
|
||||
log_url.push(':');
|
||||
url.push_str(&password);
|
||||
log_url.push_str("********");
|
||||
}
|
||||
|
||||
url.push_str("@");
|
||||
log_url.push_str("@");
|
||||
url.push('@');
|
||||
log_url.push('@');
|
||||
}
|
||||
|
||||
let host = env::var("POSTGRES_HOST").expect("DATABASE_URL or POSTGRES_HOST must be set");
|
||||
@ -64,16 +64,16 @@ fn init_db_pool() -> PgPool {
|
||||
log_url.push_str(&host);
|
||||
|
||||
if let Ok(port) = env::var("POSTGRES_PORT") {
|
||||
url.push_str(":");
|
||||
url.push(':');
|
||||
url.push_str(&port);
|
||||
log_url.push_str(":");
|
||||
log_url.push(':');
|
||||
log_url.push_str(&port);
|
||||
}
|
||||
|
||||
if let Ok(dbname) = env::var("POSTGRES_DB") {
|
||||
url.push_str("/");
|
||||
url.push('/');
|
||||
url.push_str(&dbname);
|
||||
log_url.push_str("/");
|
||||
log_url.push('/');
|
||||
log_url.push_str(&dbname);
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,7 @@ pub async fn get_static_file(uri: Uri, root: &str) -> Result<Response<Body>, (St
|
||||
Some(res) => Ok(res.into_response()),
|
||||
None => Err((
|
||||
StatusCode::INTERNAL_SERVER_ERROR,
|
||||
format!("Something went wrong"),
|
||||
"Something went wrong".to_string(),
|
||||
)),
|
||||
}
|
||||
}
|
||||
@ -59,7 +59,7 @@ pub async fn get_asset_file(filename: String, asset_type: AssetType) -> Result<R
|
||||
Ok(uri) => get_static_file(uri, root.as_str()).await,
|
||||
Err(_) => Err((
|
||||
StatusCode::INTERNAL_SERVER_ERROR,
|
||||
format!("Attempted to serve an invalid file"),
|
||||
"Attempted to serve an invalid file".to_string(),
|
||||
)),
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ use axum::extract::FromRequestParts;
|
||||
const ALLOWED_PATHS: [&str; 5] = ["/login", "/signup", "/api/login", "/api/signup", "/favicon.ico"];
|
||||
|
||||
/**
|
||||
* Middleware to require authentication for all paths except those in ALLOWED_PATHS
|
||||
* Middleware to require authentication for all paths except those in `ALLOWED_PATHS`
|
||||
*
|
||||
* If a user is not authenticated, they will be redirected to the login page
|
||||
*/
|
||||
|
@ -7,7 +7,7 @@ use crate::api::auth::get_logged_in_user;
|
||||
|
||||
/// Global front-end state
|
||||
/// Contains anything frequently needed across multiple components
|
||||
/// Behaves like a singleton, in that provide/expect_context will
|
||||
/// Behaves like a singleton, in that `provide_context`/`expect_context` will
|
||||
/// always return the same instance
|
||||
#[derive(Clone)]
|
||||
pub struct GlobalState {
|
||||
@ -47,3 +47,10 @@ impl GlobalState {
|
||||
expect_context::<Self>().play_status
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for GlobalState {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user