pub async fn get_router<M: MutableStore + 'static, T: TranslationsManager + 'static>(
    turbine: &'static Turbine<M, T>,
    opts: ServerOptions,
) -> Router {
    let router = Router::new()
        // --- File handlers ---
        .route(
            "/.perseus/bundle.js",
            get_service(ServeFile::new(opts.js_bundle.clone()).precompressed_br())
                .handle_error(handle_fs_error),
        )
        .route(
            "/.perseus/bundle.wasm",
            get_service(ServeFile::new(opts.wasm_bundle.clone()).precompressed_br())
                .handle_error(handle_fs_error),
        )
        .route(
            "/.perseus/bundle.wasm.js",
            get_service(ServeFile::new(opts.wasm_js_bundle.clone()).precompressed_br())
                .handle_error(handle_fs_error),
        )
        .nest_service(
            "/.perseus/snippets",
            get_service(ServeDir::new(opts.snippets).precompressed_br())
                .handle_error(handle_fs_error),
        );

    // --- Translation and subsequent load handlers ---
    let mut router = router
        .route(
            "/.perseus/translations/:locale",
            get(move |Path(locale): Path<String>| async move {
                ApiResponse(turbine.get_translations(&locale).await)
            }),
        )
        .route(
            "/.perseus/initial_consts.js",
            get(move || async move { ApiResponse(turbine.get_initial_consts("").await) }),
        )
        .route(
            "/.perseus/initial_consts/:locale",
            get(move |Path(locale): Path<String>| async move {
                let locale = match locale.strip_suffix(".js") {
                    Some(locale) => locale,
                    None => {
                        return ApiResponse(PerseusApiResponse::err(
                            StatusCode::BAD_REQUEST,
                            "invalid locale (needs `.js` extension)",
                        ))
                    }
                };
                ApiResponse(turbine.get_initial_consts(&locale).await)
            }),
        )
        .route(
            "/.perseus/page/:locale/*tail",
            get(
                move |Path(path_parts): Path<Vec<String>>,
                      Query(SubsequentLoadQueryParams {
                          entity_name,
                          was_incremental_match,
                      }): Query<SubsequentLoadQueryParams>,
                      http_req: Request<Body>| async move {
                    // Separate the locale from the rest of the page name
                    let locale = &path_parts[0];
                    let raw_path = path_parts[1..]
                        .iter()
                        .map(|x| x.as_str())
                        .collect::<Vec<&str>>()
                        .join("/");
                    // Get rid of the body from the request (Perseus only needs the metadata)
                    let req = Request::from_parts(http_req.into_parts().0, ());

                    ApiResponse(
                        turbine
                            .get_subsequent_load(
                                PathWithoutLocale(raw_path),
                                locale.to_string(),
                                entity_name,
                                was_incremental_match,
                                req,
                            )
                            .await,
                    )
                },
            ),
        );

    // --- Static directory and alias handlers ---
    if turbine.static_dir.exists() {
        router = router.nest_service(
            "/.perseus/static",
            get_service(ServeDir::new(&turbine.static_dir)).handle_error(handle_fs_error),
        )
    }
    for (url, static_path) in turbine.static_aliases.iter() {
        router = router.route(
            url, // This comes with a leading forward slash!
            get_service(ServeFile::new(static_path)).handle_error(handle_fs_error),
        );
    }

    // --- Initial load handler ---
    router.fallback_service(get(move |http_req: Request<Body>| async move {
        // Since this is a fallback handler, we have to do everything from the request
        // itself
        let path = http_req.uri().path().to_string();
        let http_req = Request::from_parts(http_req.into_parts().0, ());

        ApiResponse(
            turbine
                .get_initial_load(PathMaybeWithLocale(path), http_req)
                .await,
        )
    }))
}
Gets the `Router` needed to configure an existing Axum app for Perseus, and
should be provided after any other routes, as they include a wildcard route.
packages/perseus-axum/src/lib.rs