use axum::{ extract::{Path, State}, response::{self, IntoResponse}, }; use axum_extra::TypedHeader; use headers::IfNoneMatch; use crate::{ error::Internal, invite, invite::app::Invites, ui::{ assets, assets::{Asset, Assets}, error::NotFound, }, }; pub async fn handler( State(invites): State, Path(invite): Path, TypedHeader(if_none_match): TypedHeader, ) -> Result { if invites.get(&invite).await?.is_some() { let index = assets::Response::index(&if_none_match)?; Ok(Response::Found(index)) } else { let index = Assets::index()?; Ok(Response::NotFound(index)) } } pub enum Response { Found(assets::Response), NotFound(Asset), } impl IntoResponse for Response { fn into_response(self) -> response::Response { match self { Self::Found(asset) => asset.into_response(), Self::NotFound(asset) => NotFound(asset).into_response(), } } }