From 94450f5a88119defcd3c569cb8c763c2ef6e39f5 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Fri, 13 Dec 2024 02:59:05 +0100 Subject: [PATCH] `rdserver`: Make use of the `connect` feature --- acrate_rdserver/Cargo.toml | 2 +- acrate_rdserver/src/config.rs | 1 - acrate_rdserver/src/route.rs | 5 +++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/acrate_rdserver/Cargo.toml b/acrate_rdserver/Cargo.toml index 43b0148..bdff788 100644 --- a/acrate_rdserver/Cargo.toml +++ b/acrate_rdserver/Cargo.toml @@ -10,7 +10,7 @@ keywords = ["jrd", "xrd", "hostmeta", "webfinger", "resource-descriptor"] categories = ["web-programming"] [dependencies] -acrate_database = { path = "../acrate_database" } +acrate_database = { path = "../acrate_database", features = ["connect"] } acrate_rd = { path = "../acrate_rd" } anyhow = "1.0.93" axum = { version = "0.7.7", features = ["macros"] } diff --git a/acrate_rdserver/src/config.rs b/acrate_rdserver/src/config.rs index feb7905..535a5c4 100644 --- a/acrate_rdserver/src/config.rs +++ b/acrate_rdserver/src/config.rs @@ -1,4 +1,3 @@ micronfig::config!( - ACRATE_WEBFINGER_DATABASE_URL: String, ACRATE_WEBFINGER_BIND_ADDRESS: String, ); diff --git a/acrate_rdserver/src/route.rs b/acrate_rdserver/src/route.rs index 9821182..5405f20 100644 --- a/acrate_rdserver/src/route.rs +++ b/acrate_rdserver/src/route.rs @@ -6,6 +6,7 @@ use axum::http::{HeaderMap, Response, StatusCode}; use axum_extra::extract::Query; use mediatype::{MediaTypeBuf, MediaTypeList}; use serde::Deserialize; +use acrate_database::connect::connect_async; use acrate_database::diesel::GroupedBy; use acrate_database::diesel_async::{AsyncConnection, AsyncPgConnection}; use acrate_database::meta::{MetaAlias, MetaLink, MetaLinkProperty, MetaLinkTitle, MetaProperty, MetaSubject}; @@ -17,7 +18,7 @@ pub async fn healthcheck_handler() -> Result { log::debug!("Handling an healthcheck request!"); log::trace!("Making sure the database is up..."); - let _conn = AsyncPgConnection::establish(config::ACRATE_WEBFINGER_DATABASE_URL()) + let _conn = connect_async() .await .map_err(|_| StatusCode::BAD_GATEWAY)?; @@ -59,7 +60,7 @@ pub async fn webfinger_handler( let mut response = Response::new("".to_string()); - let mut conn = AsyncPgConnection::establish(config::ACRATE_WEBFINGER_DATABASE_URL()) + let mut conn = connect_async() .await .map_err(|_| StatusCode::BAD_GATEWAY)?;