pub async fn configurer<M: MutableStore + 'static, T: TranslationsManager + 'static>(
    turbine: &'static Turbine<M, T>,
    opts: ServerOptions,
) -> impl FnOnce(&mut actix_web::web::ServiceConfig) {
    move |cfg: &mut web::ServiceConfig| {
        let snippets_dir = opts.snippets.clone();
        cfg
            .app_data(web::Data::new(opts))
            // --- File handlers ---
            .route("/.perseus/bundle.js", web::get().to(js_bundle))
            .route("/.perseus/bundle.wasm", web::get().to(wasm_bundle))
            .route("/.perseus/bundle.wasm.js", web::get().to(wasm_js_bundle))
            .service(Files::new("/.perseus/snippets", &snippets_dir))
            // --- Translation and subsequent load handlers
            .route(
                "/.perseus/translations/{locale}",
                web::get().to(move |http_req: HttpRequest| async move {
                    let locale = http_req.match_info().query("locale");
                    ApiResponse(turbine.get_translations(locale).await)
                }),
            )
            .route(
                "/.perseus/initial_consts/{locale}.js",
                web::get().to(move |http_req: HttpRequest| async move {
                    let locale = http_req.match_info().query("locale");
                    ApiResponse(turbine.get_initial_consts(locale).await)
                })
            )
            .route(
                "/.perseus/initial_consts.js",
                web::get().to(move || async move {
                    ApiResponse(turbine.get_initial_consts("").await)
                })
            )
            .route(
                // We capture the `.json` ending in the handler
                "/.perseus/page/{locale}/{filename:.*}",
                web::get().to(move |http_req: HttpRequest, web::Query(query_params): web::Query<SubsequentLoadQueryParams>| async move {
                    let raw_path = http_req.match_info().query("filename").to_string();
                    let locale = http_req.match_info().query("locale");
                    let SubsequentLoadQueryParams { entity_name, was_incremental_match } = query_params;
                    let http_req = match convert_req(&http_req) {
                        Ok(req) => req,
                        Err(err) => return ApiResponse(PerseusApiResponse::err(StatusCode::BAD_REQUEST, &err))
                    };

                    ApiResponse(turbine.get_subsequent_load(
                        PathWithoutLocale(raw_path),
                        locale.to_string(),
                        entity_name,
                        was_incremental_match,
                        http_req
                    ).await)
                }),
            );
        // --- Static directory and alias handlers
        if turbine.static_dir.exists() {
            cfg.service(Files::new("/.perseus/static", &turbine.static_dir));
        }
        for url in turbine.static_aliases.keys() {
            cfg.route(
                url,
                web::get().to(|req| async { static_alias(turbine, req).await }),
            );
        }
        // --- Initial load handler ---
        cfg.route(
            "{route:.*}",
            web::get().to(move |http_req: HttpRequest| async move {
                let raw_path = http_req.path().to_string();
                let http_req = match convert_req(&http_req) {
                    Ok(req) => req,
                    Err(err) => {
                        return ApiResponse(PerseusApiResponse::err(StatusCode::BAD_REQUEST, &err))
                    }
                };
                ApiResponse(
                    turbine
                        .get_initial_load(PathMaybeWithLocale(raw_path), http_req)
                        .await,
                )
            }),
        );
    }
}
Configures an existing Actix Web app for Perseus. This returns a function
that does the configuring so it can take arguments. This includes a complete
wildcard handler (`*`), and so it should be configured after any other
routes on your server.
packages/perseus-actix-web/src/lib.rs