diff options
Diffstat (limited to 'src/ui.rs')
| -rw-r--r-- | src/ui.rs | 14 |
1 files changed, 13 insertions, 1 deletions
@@ -9,7 +9,7 @@ use axum::{ use mime_guess::Mime; use rust_embed::EmbeddedFile; -use crate::{app::App, channel, error::Internal, login::Login}; +use crate::{app::App, channel, error::Internal, invite, login::Login}; #[derive(rust_embed::Embed)] #[folder = "target/ui"] @@ -41,6 +41,7 @@ pub fn router(app: &App) -> Router<App> { .route("/", get(root)) .route("/login", get(login)) .route("/ch/:channel", get(channel)) + .route("/invite/:invite", get(invite)) .route_layer(middleware::from_fn_with_state(app.clone(), setup_required)), ] .into_iter() @@ -85,6 +86,17 @@ async fn channel( } } +async fn invite( + State(app): State<App>, + Path(invite): Path<invite::Id>, +) -> Result<impl IntoResponse, Internal> { + match app.invites().get(&invite).await { + Ok(_) => Ok(Assets::index()?.into_response()), + Err(invite::app::Error::NotFound(_)) => Ok(NotFound(Assets::index()?).into_response()), + Err(other) => Err(Internal::from(other)), + } +} + struct Asset(Mime, EmbeddedFile); impl IntoResponse for Asset { |
