// ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ // ┃ Copyright: (c) 2023, Mike 'PhiSyX' S. (https://github.com/PhiSyX) ┃ // ┃ SPDX-License-Identifier: MPL-2.0 ┃ // ┃ ╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌ ┃ // ┃ ┃ // ┃ This Source Code Form is subject to the terms of the Mozilla Public ┃ // ┃ License, v. 2.0. If a copy of the MPL was not distributed with this ┃ // ┃ file, You can obtain one at https://mozilla.org/MPL/2.0/. ┃ // ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ use lexa_framework::routing; use crate::view_render_site::applications::ApplicationState; use crate::view_render_site::controllers::PagesController; // --------- // // Structure // // --------- // pub struct PagesHTMLRouter; pub struct PagesJSONRouter; // ----------- // // Énumération // // ----------- // lexa_framework::routes! { pub enum PagesRouteIds<'r> { #[route(url = "/json")] Json, #[route(url = "/html")] Html, #[route(url = "/html/{name}")] HtmlName { name: &'r str }, } } // -------------- // // Implémentation // -> Interface // -------------- // impl lexa_framework::ApplicationRouter for PagesHTMLRouter { type State = ApplicationState; fn routes() -> routing::RouteCollection { Self::router_collection() .add( routing::Router::path(PagesRouteIds::Html) .get(PagesController::html), ) .add( routing::Router::path(PagesRouteIds::HtmlName { name: ":name" }) .get(PagesController::html_arg), ) } } impl lexa_framework::ApplicationRouter for PagesJSONRouter { type State = ApplicationState; fn routes() -> routing::RouteCollection { Self::router_collection().add( routing::Router::path(PagesRouteIds::Json) .get(PagesController::json), ) } }