pub async fn get_initial_load(
        &self,
        raw_path: PathMaybeWithLocale,
        req: Request,
    ) -> ApiResponse {
        // Decode the URL so we can work with spaces and special characters
        let raw_path = match urlencoding::decode(&raw_path) {
            Ok(path) => path.to_string(),
            Err(err) => {
                return self.html_err(
                    400,
                    fmt_err(&ServerError::UrlDecodeFailed { source: err }),
                    None,
                )
            }
        };
        let raw_path = PathMaybeWithLocale(raw_path.as_str().to_string());

        // Run the routing algorithm to figure out what to do here
        let path_slice = get_path_slice(&raw_path);
        let verdict = match_route(&path_slice, &self.render_cfg, &self.entities, &self.locales);
        match verdict.into_full(&self.entities) {
            FullRouteVerdict::Found(FullRouteInfo {
                path,
                entity,
                locale,
                was_incremental_match,
            }) => {
                // Get the translations to interpolate into the page
                let translations_str = self
                    .translations_manager
                    .get_translations_str_for_locale(locale.clone())
                    .await;
                let translations_str = match translations_str {
                    Ok(translations) => translations,
                    // We know for sure that this locale is supported, so there's been an internal
                    // server error if it can't be found
                    Err(err) => {
                        return self.html_err(500, fmt_err(&err), None);
                    }
                };

                // We can use those to get a translator efficiently
                let translator = match self
                    .translations_manager
                    .get_translator_for_translations_str(locale.clone(), translations_str.clone())
                    .await
                {
                    Ok(translator) => translator,
                    // We need to give a proper translator to the error pages, which we can't
                    Err(err) => return self.html_err(500, fmt_err(&err), None),
                };

                // This returns both the page data and the most up-to-date global state
                let res = self
                    .get_initial_load_for_path(
                        path,
                        &translator,
                        entity,
                        was_incremental_match,
                        req,
                    )
                    .await;
                let (page_data, global_state) = match res {
                    Ok(data) => data,
                    Err(err) => {
                        return self.html_err(
                            err_to_status_code(&err),
                            fmt_err(&err),
                            Some(&translator),
                        )
                    }
                };

                let final_html = self
                    .html_shell
                    .as_ref()
                    .unwrap()
                    .clone()
                    .page_data(&page_data, &global_state, &locale)
                    .to_string();
                // NOTE: Yes, the user can fully override the content type...I have yet to find
                // a good use for this given the need to generate a `View`
                // though...
                let mut response = ApiResponse::ok(&final_html).content_type("text/html");

                // Generate and add HTTP headers
                let headers = match entity.get_headers(
                    TemplateState::from_value(page_data.state),
                    global_state,
                    Some(&translator),
                ) {
                    Ok(headers) => headers,
                    // The pointlessness of returning an error here is well documented
                    Err(err) => {
                        return self.html_err(
                            err_to_status_code(&err),
                            fmt_err(&err),
                            Some(&translator),
                        )
                    }
                };
                for (key, val) in headers {
                    response.add_header(key.unwrap(), val);
                }

                response
            }
            FullRouteVerdict::LocaleDetection(redirect_path) => {
                // Locale redirection pages still need to have the global state (unlocalized,
                // see #267), but we obviously won't be able to output a nice
                // internationalized error if this goes wrong here
                let global_state = match self.get_full_global_state(req).await {
                    Ok(state) => state,
                    Err(err) => {
                        return self.html_err(err_to_status_code(&err), fmt_err(&err), None)
                    }
                };
                // TODO Parse the `Accept-Language` header and return a proper redirect
                // Construct a locale redirection fallback
                let html = self
                    .html_shell
                    .as_ref()
                    .unwrap() // We assume the app has been built
                    .clone()
                    .locale_redirection_fallback(
                        // This is the dumb destination we'd use if Wasm isn't enabled (the default
                        // locale). It has *zero* bearing on what the Wasm
                        // bundle will do.
                        &format!(
                            "{}/{}/{}",
                            get_path_prefix_server(),
                            &self.locales.default,
                            // This is a `PathWithoutLocale`
                            redirect_path.0,
                        ),
                        &global_state,
                    )
                    .to_string();
                // TODO Headers? They weren't here in the old code...
                // This isn't an error, but that's how this API expresses it (302 redirect)
                ApiResponse::err(StatusCode::FOUND, &html).content_type("text/html")
            }
            // Any unlocalized 404s would go to a redirect first
            FullRouteVerdict::NotFound { locale } => {
                // Get the translations to interpolate into the page
                let translations_str = self
                    .translations_manager
                    .get_translations_str_for_locale(locale.clone())
                    .await;
                let translations_str = match translations_str {
                    Ok(translations) => translations,
                    // We know for sure that this locale is supported, so there's been an internal
                    // server error if it can't be found
                    Err(err) => {
                        return self.html_err(500, fmt_err(&err), None);
                    }
                };

                // We can use those to get a translator efficiently
                let translator = match self
                    .translations_manager
                    .get_translator_for_translations_str(locale, translations_str.clone())
                    .await
                {
                    Ok(translator) => translator,
                    // We need to give a proper translator to the error pages, which we can't
                    Err(err) => return self.html_err(500, fmt_err(&err), None),
                };

                self.html_err(404, "page not found".to_string(), Some(&translator))
            }
        }
    }
The endpoint for getting the full HTML contents of a page with no round
trips (except for suspended states and/or delayed widgets). This is
what should be returned to the user when they first ask for a page
in the app.

This expects to take a raw path without the locale split out that still
needs URL decoding.

If there's an error anywhere in this function, it will return the HTML
of a proper error page.

Initial loads *always* (even in the case of errors) have the MIME type
`text/html`.
packages/perseus/src/turbine/server.rs