#
mcaptcha/pages/
routes.rs

    1// Copyright (C) 2022  Aravinth Manivannan <realaravinth@batsense.net>
    2// SPDX-FileCopyrightText: 2023 Aravinth Manivannan <realaravinth@batsense.net>
    3//
    4// SPDX-License-Identifier: AGPL-3.0-or-later
    5
    6use actix_auth_middleware::GetLoginRoute;
    7
    8use super::auth::routes::Auth;
    9use super::errors::routes::Errors;
    10use super::panel::routes::Panel;
    11
    12pub const ROUTES: Routes = Routes::new();
    13
    14pub struct Routes {
    15    pub home: &'static str,
    16    pub auth: Auth,
    17    pub panel: Panel,
    18    pub errors: Errors,
    19    pub about: &'static str,
    20    pub sitemap: &'static str,
    21    pub thanks: &'static str,
    22    pub donate: &'static str,
    23    pub security: &'static str,
    24    pub privacy: &'static str,
    25}
    26
    27impl Routes {
    28    const fn new() -> Routes {
    29        let panel = Panel::new();
    30        let home = panel.home;
    31        Routes {
    32            auth: Auth::new(),
    33            panel,
    34            home,
    35            errors: Errors::new(),
    36            about: "/about",
    37            sitemap: "/sitemap.xml",
    38            thanks: "/thanks",
    39            donate: "/donate",
    40            security: "/security",
    41            privacy: "/privacy-policy",
    42        }
    43    }
    44
    45    pub const fn get_sitemap() -> [&'static str; 7] {
    46        let a = Auth::get_sitemap();
    47        let p = Panel::get_sitemap();
    48        [a[0], a[1], p[0], p[1], p[2], p[3], p[4]]
    49    }
    50}
    51
    52impl GetLoginRoute for Routes {
    53    fn get_login_route(&self, src: Option<&str>) -> String {
    54        self.auth.get_login_route(src)
    55    }
    56}
    57
    58#[cfg(test)]
    59mod tests {
    60    use super::*;
    61
    62    #[test]
    63    fn sitemap_works() {
    64        Routes::get_sitemap();
    65    }
    66}