rdserver: Make use of the connect feature

This commit is contained in:
Steffo 2024-12-13 02:59:05 +01:00
parent 7b6af31ed5
commit 94450f5a88
Signed by: steffo
GPG key ID: 5ADA3868646C3FC0
3 changed files with 4 additions and 4 deletions

View file

@ -10,7 +10,7 @@ keywords = ["jrd", "xrd", "hostmeta", "webfinger", "resource-descriptor"]
categories = ["web-programming"] categories = ["web-programming"]
[dependencies] [dependencies]
acrate_database = { path = "../acrate_database" } acrate_database = { path = "../acrate_database", features = ["connect"] }
acrate_rd = { path = "../acrate_rd" } acrate_rd = { path = "../acrate_rd" }
anyhow = "1.0.93" anyhow = "1.0.93"
axum = { version = "0.7.7", features = ["macros"] } axum = { version = "0.7.7", features = ["macros"] }

View file

@ -1,4 +1,3 @@
micronfig::config!( micronfig::config!(
ACRATE_WEBFINGER_DATABASE_URL: String,
ACRATE_WEBFINGER_BIND_ADDRESS: String, ACRATE_WEBFINGER_BIND_ADDRESS: String,
); );

View file

@ -6,6 +6,7 @@ use axum::http::{HeaderMap, Response, StatusCode};
use axum_extra::extract::Query; use axum_extra::extract::Query;
use mediatype::{MediaTypeBuf, MediaTypeList}; use mediatype::{MediaTypeBuf, MediaTypeList};
use serde::Deserialize; use serde::Deserialize;
use acrate_database::connect::connect_async;
use acrate_database::diesel::GroupedBy; use acrate_database::diesel::GroupedBy;
use acrate_database::diesel_async::{AsyncConnection, AsyncPgConnection}; use acrate_database::diesel_async::{AsyncConnection, AsyncPgConnection};
use acrate_database::meta::{MetaAlias, MetaLink, MetaLinkProperty, MetaLinkTitle, MetaProperty, MetaSubject}; use acrate_database::meta::{MetaAlias, MetaLink, MetaLinkProperty, MetaLinkTitle, MetaProperty, MetaSubject};
@ -17,7 +18,7 @@ pub async fn healthcheck_handler() -> Result<StatusCode, StatusCode> {
log::debug!("Handling an healthcheck request!"); log::debug!("Handling an healthcheck request!");
log::trace!("Making sure the database is up..."); log::trace!("Making sure the database is up...");
let _conn = AsyncPgConnection::establish(config::ACRATE_WEBFINGER_DATABASE_URL()) let _conn = connect_async()
.await .await
.map_err(|_| StatusCode::BAD_GATEWAY)?; .map_err(|_| StatusCode::BAD_GATEWAY)?;
@ -59,7 +60,7 @@ pub async fn webfinger_handler(
let mut response = Response::new("".to_string()); let mut response = Response::new("".to_string());
let mut conn = AsyncPgConnection::establish(config::ACRATE_WEBFINGER_DATABASE_URL()) let mut conn = connect_async()
.await .await
.map_err(|_| StatusCode::BAD_GATEWAY)?; .map_err(|_| StatusCode::BAD_GATEWAY)?;