ssowat-rs/src/routes/mod.rs

27 lines
666 B
Rust
Raw Normal View History

2023-08-18 10:59:50 +02:00
use axum::{
routing::{get, post},
Router,
};
2023-08-22 19:29:40 +02:00
use tower_cookies::CookieManagerLayer;
2023-08-18 10:59:50 +02:00
use crate::state::RoutableAppState;
mod index;
mod login;
mod logout;
2023-08-18 10:59:50 +02:00
/// Build a router for the application, in a specific subpath eg `/yunohost/sso/`
pub fn router(subpath: Option<String>, state: RoutableAppState) -> Router {
let app = Router::new()
.route("/", get(index::route))
2023-08-22 17:00:55 +02:00
.route("/login/", post(login::route))
.route("/logout/", get(logout::route))
2023-08-22 19:29:40 +02:00
.layer(CookieManagerLayer::new())
2023-08-18 10:59:50 +02:00
.with_state(state);
if let Some(p) = subpath {
Router::new()
.nest(&p, app)
} else {
app
}
2023-08-23 12:33:06 +00:00
}