aboutsummaryrefslogtreecommitdiff
path: root/server/src/ui/home.rs
blob: 4e9fd2846138314b92cb911115b67611e54ce156 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
/*
    This file is part of jellything (https://codeberg.org/metamuffin/jellything)
    which is licensed under the GNU Affero General Public License (version 3); see /COPYING.
    Copyright (C) 2026 metamuffin <metamuffin.org>
*/

use super::error::MyResult;
use rocket::{get, response::content::RawHtml, serde::json::Json, Either};

#[get("/home")]
pub fn r_home(ri: RequestInfo) -> MyResult<Either<RawHtml<String>, Json<ApiHomeResponse>>> {
    let r = jellylogic::home::home(&ri.session)?;

    Ok(if matches!(ri.accept, Accept::Json) {
        Either::Right(Json(r))
    } else {
        Either::Left(RawHtml(render_page(
            &HomePage { lang: &ri.lang, r },
            ri.render_info(),
        )))
    })
}