docs: clean up repo and add doc strings
This commit is contained in:
parent
e1c27ca308
commit
efd1137c71
3 changed files with 17 additions and 5 deletions
|
|
@ -19,6 +19,12 @@ pub struct Settings {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(serde::Deserialize, Clone)]
|
#[derive(serde::Deserialize, Clone)]
|
||||||
|
/// The email client settings.
|
||||||
|
///
|
||||||
|
/// * `base_url`: The base URL for the email client
|
||||||
|
/// * `sender_email`: The email address of the sender
|
||||||
|
/// * `authorization_token`: The authorization token
|
||||||
|
/// * `timeout_milliseconds`: The timeout in milliseconds
|
||||||
pub struct EmailClientSettings {
|
pub struct EmailClientSettings {
|
||||||
pub base_url: String,
|
pub base_url: String,
|
||||||
pub sender_email: String,
|
pub sender_email: String,
|
||||||
|
|
@ -31,6 +37,7 @@ pub struct EmailClientSettings {
|
||||||
///
|
///
|
||||||
/// * `port`: The port to listen on
|
/// * `port`: The port to listen on
|
||||||
/// * `host`: The host address to listen on
|
/// * `host`: The host address to listen on
|
||||||
|
/// * `base_url`: The base URL for the application
|
||||||
pub struct ApplicationSettings {
|
pub struct ApplicationSettings {
|
||||||
#[serde(deserialize_with = "deserialize_number_from_string")]
|
#[serde(deserialize_with = "deserialize_number_from_string")]
|
||||||
pub port: u16,
|
pub port: u16,
|
||||||
|
|
|
||||||
|
|
@ -12,12 +12,19 @@ pub struct Parameters {
|
||||||
subscription_token: String,
|
subscription_token: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
// #[tracing::instrument(name = "Confirm a pending subscriber", skip(_parameters))]
|
#[tracing::instrument(name = "Confirm a pending subscriber", skip(_parameters))]
|
||||||
|
/// Confirm a pending subscriber.
|
||||||
|
/// # Parameters
|
||||||
|
/// - subscription_token: The subscription token.
|
||||||
|
/// # Returns
|
||||||
|
/// - 200 OK: The subscriber has been confirmed.
|
||||||
|
/// - 400 Bad Request: The subscription token is missing.
|
||||||
pub async fn confirm(Query(_parameters): Query<Parameters>) -> Response {
|
pub async fn confirm(Query(_parameters): Query<Parameters>) -> Response {
|
||||||
println!("subscription_token: {}", _parameters.subscription_token);
|
println!("subscription_token: {}", _parameters.subscription_token);
|
||||||
(StatusCode::OK,).into_response()
|
(StatusCode::OK,).into_response()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The routes for subscription confirmation.
|
||||||
pub fn routes_subscriptions_confirm() -> Router<AppState> {
|
pub fn routes_subscriptions_confirm() -> Router<AppState> {
|
||||||
Router::new().route("/subscriptions/confirm", get(confirm))
|
Router::new().route("/subscriptions/confirm", get(confirm))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -63,15 +63,13 @@ impl Application {
|
||||||
);
|
);
|
||||||
let listener = TcpListener::bind(&address).await?;
|
let listener = TcpListener::bind(&address).await?;
|
||||||
|
|
||||||
// FIXME: don't clone if not necessary
|
|
||||||
let state = AppState {
|
let state = AppState {
|
||||||
db_pool: connection_pool.clone(),
|
db_pool: connection_pool,
|
||||||
email_client: email_client.clone(),
|
email_client,
|
||||||
base_url: ApplicationBaseUrl(configuration.application.base_url),
|
base_url: ApplicationBaseUrl(configuration.application.base_url),
|
||||||
};
|
};
|
||||||
|
|
||||||
let app = Router::new()
|
let app = Router::new()
|
||||||
// TODO: check whether state cloning is what we want
|
|
||||||
.merge(crate::routes::routes_subscriptions())
|
.merge(crate::routes::routes_subscriptions())
|
||||||
.merge(crate::routes::routes_subscriptions_confirm())
|
.merge(crate::routes::routes_subscriptions_confirm())
|
||||||
.with_state(state)
|
.with_state(state)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue