blob: 669e5f13c95ea21b46751947f46331242286b42f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
//! nested `/.me`
//!
//! Routes that return a 307 Temporary Redirect to information about me. These
//! routes use different schemes to open the email application or phone dailer etc. etc.
use axum::{Extension, Router, body::Body, http::StatusCode, response::Response, routing::get};
use crate::{RuntimeError, config::Settings, state::SplormState};
/// Routes nested under /.me
pub fn routes() -> Router<SplormState> {
Router::new().route("/email", get(email))
}
async fn email(Extension(settings): Extension<Settings>) -> Result<Response, RuntimeError> {
Response::builder()
.status(StatusCode::TEMPORARY_REDIRECT)
.header("Location", format!("mailto:{}", settings.me_email()))
.body(Body::empty())
.map_err(|_| RuntimeError::Unknown)
}
|