ssowat-rs/src/routes/mod.rs

24 lines
545 B
Rust
Raw Normal View History

2023-08-18 10:59:50 +02:00
use axum::{
extract::State,
routing::{get, post},
Router,
};
use crate::state::RoutableAppState;
mod index;
mod login;
/// 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))
2023-08-18 10:59:50 +02:00
.with_state(state);
if let Some(p) = subpath {
Router::new()
.nest(&p, app)
} else {
app
}
}