pub trait LocaleRouterExt<St>: Sized {
// Required method
fn redirect_to_locale<L: Locale + Send + Sync>(self, home: Route<L>) -> Self;
}Expand description
Adds the redirect from / to the page in the visitor’s language to an axum [Router].
Required Methods§
Sourcefn redirect_to_locale<L: Locale + Send + Sync>(self, home: Route<L>) -> Self
fn redirect_to_locale<L: Locale + Send + Sync>(self, home: Route<L>) -> Self
Answers GET / with a redirect to home in the locale the visitor’s browser asks for.
The locale comes from negotiate over the Accept-Language header.
The redirect is a 307 Temporary Redirect with Vary: Accept-Language,
because another browser may be sent to another locale.
hypersig::routes! {
fn pages(Router<()>);
const HOME: Route<Lang> = "/{lang}" => home;
}
let _app: Router = pages(Router::new()).redirect_to_locale(HOME);Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".