use axum::response::{self, IntoResponse, Redirect}; use axum_extra::TypedHeader; use headers::IfNoneMatch; use crate::{error::Internal, token::extract::Identity, ui::assets::Response}; pub async fn handler( identity: Option, TypedHeader(if_none_match): TypedHeader, ) -> Result { let _ = identity.ok_or(Error::NotLoggedIn)?; Response::index(&if_none_match).map_err(Error::Internal) } pub enum Error { NotLoggedIn, Internal(Internal), } impl IntoResponse for Error { fn into_response(self) -> response::Response { match self { Self::NotLoggedIn => Redirect::temporary("/login").into_response(), Self::Internal(error) => error.into_response(), } } }