use crate::web::{empty_response, Context, HandlerResult};
use crate::{bridges, handlers};
use http::{Method, StatusCode};
pub async fn router(ctx: &mut Context) -> HandlerResult {
match (&ctx.method, ctx.uri.path()) {
(&Method::GET, "/.well-known/openid-configuration") => handlers::auth::discovery(ctx).await,
(&Method::GET, "/keys.json") => handlers::auth::key_set(ctx).await,
(&Method::GET, "/auth") | (&Method::POST, "/auth") => handlers::auth::auth(ctx).await,
(&Method::POST, "/normalize") => handlers::normalize::normalize(ctx).await,
(&Method::POST, "/token") => handlers::token::token(ctx).await,
(&Method::GET, "/callback") => handlers::rewrite_to_post::rewrite_to_post(ctx).await,
(&Method::POST, "/callback") => bridges::oidc::callback(ctx).await,
(&Method::GET, "/confirm") => handlers::rewrite_to_post::rewrite_to_post(ctx).await,
(&Method::POST, "/confirm") => bridges::email::confirmation(ctx).await,
(&Method::GET, "/") => handlers::pages::index(ctx).await,
(&Method::GET, "/ver.txt") => handlers::pages::version(ctx).await,
(&Method::GET, "/metrics") => handlers::pages::metrics(ctx).await,
(&Method::GET, _) | (&Method::HEAD, _) => handlers::pages::static_(ctx).await,
_ => Ok(empty_response(StatusCode::BAD_REQUEST)),
}
}