use axum::{extract::State, routing::get, Router}; use maud::Markup; use super::templates; use crate::{app::App, error::InternalError, login::repo::logins::Login}; async fn index(State(app): State, login: Option) -> Result { match login { None => Ok(templates::unauthenticated()), Some(login) => index_authenticated(app, login).await, } } async fn index_authenticated(app: App, login: Login) -> Result { let channels = app.index().for_authenticated().await?; Ok(templates::authenticated(login, &channels)) } pub fn router() -> Router { Router::new().route("/", get(index)) }