Package io.micronaut.http.server
Class HttpServerConfiguration.HttpLocaleResolutionConfigurationProperties
- java.lang.Object
-
- io.micronaut.http.server.HttpServerConfiguration.HttpLocaleResolutionConfigurationProperties
-
- All Implemented Interfaces:
io.micronaut.core.util.locale.LocaleResolutionConfiguration,HttpLocaleResolutionConfiguration
- Enclosing class:
- HttpServerConfiguration
@ConfigurationProperties("locale-resolution") public static class HttpServerConfiguration.HttpLocaleResolutionConfigurationProperties extends java.lang.Object implements HttpLocaleResolutionConfigurationConfiguration for locale resolution used byHttpLocaleResolver.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringPREFIX
-
Constructor Summary
Constructors Constructor Description HttpLocaleResolutionConfigurationProperties()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Optional<java.lang.String>getCookieName()java.util.LocalegetDefaultLocale()java.util.Optional<java.util.Locale>getFixed()java.util.Optional<java.lang.String>getSessionAttribute()booleanisHeader()voidsetCookieName(java.lang.String cookieName)Sets the name of the cookie that is used to store the locale.voidsetDefaultLocale(java.util.Locale defaultLocale)Sets the locale that will be used if the locale cannot be resolved through any means.voidsetFixed(java.util.Locale fixed)Set the language tag for the locale.voidsetHeader(boolean header)Set to true if the locale should be resolved from the `Accept-Language` header.voidsetSessionAttribute(java.lang.String sessionAttribute)Sets the key in the session to look for the locale.
-
-
-
Field Detail
-
PREFIX
public static final java.lang.String PREFIX
- See Also:
- Constant Field Values
-
-
Method Detail
-
getFixed
@NonNull public java.util.Optional<java.util.Locale> getFixed()
- Specified by:
getFixedin interfaceio.micronaut.core.util.locale.LocaleResolutionConfiguration- Returns:
- The fixed locale
-
setFixed
public void setFixed(@Nullable java.util.Locale fixed)Set the language tag for the locale. Supports BCP 47 language tags (e.g. "en-US") and ISO standard (e.g "en_US").- Parameters:
fixed- The fixed locale
-
getSessionAttribute
@NonNull public java.util.Optional<java.lang.String> getSessionAttribute()
- Specified by:
getSessionAttributein interfaceHttpLocaleResolutionConfiguration- Returns:
- The key in the session that stores the locale
-
setSessionAttribute
public void setSessionAttribute(@Nullable java.lang.String sessionAttribute)Sets the key in the session to look for the locale.- Parameters:
sessionAttribute- The session attribute key
-
getDefaultLocale
@NonNull public java.util.Locale getDefaultLocale()
- Specified by:
getDefaultLocalein interfaceio.micronaut.core.util.locale.LocaleResolutionConfiguration- Returns:
- The locale to be used if one cannot be resolved.
-
setDefaultLocale
public void setDefaultLocale(@NonNull java.util.Locale defaultLocale)Sets the locale that will be used if the locale cannot be resolved through any means. Defaults to the system default.- Parameters:
defaultLocale- The default locale.
-
getCookieName
@NonNull public java.util.Optional<java.lang.String> getCookieName()
- Specified by:
getCookieNamein interfaceHttpLocaleResolutionConfiguration- Returns:
- The name of the cookie that contains the locale.
-
setCookieName
public void setCookieName(@Nullable java.lang.String cookieName)Sets the name of the cookie that is used to store the locale.- Parameters:
cookieName- The name of the cookie used to store the locale
-
isHeader
public boolean isHeader()
- Specified by:
isHeaderin interfaceHttpLocaleResolutionConfiguration- Returns:
- True if the accept header should be searched for the locale.
-
setHeader
public void setHeader(boolean header)
Set to true if the locale should be resolved from the `Accept-Language` header. Default value (true).- Parameters:
header- Header resolution
-
-