use super::RouteMountError;
use axum::Router;
use systemprompt_models::modules::ApiPaths;
use super::protocol::MountCtx;
use crate::services::middleware::RouterExt;
use crate::services::middleware::authz::AuthzPolicy;
pub(super) fn mount_gateway(
mut router: Router,
mount: &MountCtx<'_>,
) -> Result<Router, RouteMountError> {
let ctx = mount.ctx;
let gateway = crate::routes::gateway::gateway_mount_router(ctx, mount.limits)
.map_err(|source| RouteMountError::initialization("gateway", source))?;
router = router.nest(ApiPaths::GATEWAY_BASE, gateway);
router = router.nest(
ApiPaths::GATEWAY_PUBLIC_BASE,
crate::routes::gateway::sessions::public_router(ctx)
.with_rate_limit(
mount.limits,
ctx.config().rate_limits.oauth_public_per_second,
"oauth_public",
)?
.with_auth(*mount.public_middleware, AuthzPolicy::public()),
);
Ok(router)
}