Package io.micronaut.http.server
Class HttpServerConfiguration.CorsConfiguration
java.lang.Object
io.micronaut.http.server.HttpServerConfiguration.CorsConfiguration
- All Implemented Interfaces:
Toggleable
- Enclosing class:
- HttpServerConfiguration
@ConfigurationProperties("cors")
public static class HttpServerConfiguration.CorsConfiguration
extends Object
implements Toggleable
Configuration for CORS.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final boolean
static final boolean
static final boolean
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
boolean
boolean
void
setConfigurations
(Map<String, CorsOriginConfiguration> configurations) Sets the CORS configurations.void
setEnabled
(boolean enabled) Sets whether CORS is enabled.void
setLocalhostPassThrough
(boolean localhostPassThrough) Sets whether localhost pass-through is enabled.void
setSingleHeader
(boolean singleHeader) Sets whether CORS header values should be joined into a single header.
-
Field Details
-
DEFAULT_ENABLED
public static final boolean DEFAULT_ENABLED- See Also:
-
DEFAULT_SINGLE_HEADER
public static final boolean DEFAULT_SINGLE_HEADER- See Also:
-
DEFAULT_LOCALHOST_PASS_THROUGH
public static final boolean DEFAULT_LOCALHOST_PASS_THROUGH- See Also:
-
-
Constructor Details
-
CorsConfiguration
public CorsConfiguration()
-
-
Method Details
-
isEnabled
public boolean isEnabled()- Specified by:
isEnabled
in interfaceToggleable
- Returns:
- Whether cors is enabled. Defaults to false.
-
isLocalhostPassThrough
public boolean isLocalhostPassThrough()- Returns:
- Whether localhost pass-through is enabled. Defaults to false.
- Since:
- 3.8.5
-
getConfigurations
- Returns:
- The cors configurations
-
isSingleHeader
public boolean isSingleHeader()- Returns:
- Whether headers should be combined into a single header
-
setEnabled
public void setEnabled(boolean enabled) Sets whether CORS is enabled. Default value (false)- Parameters:
enabled
- True if CORS is enabled
-
setLocalhostPassThrough
public void setLocalhostPassThrough(boolean localhostPassThrough) Sets whether localhost pass-through is enabled. Default value false. Setting this to true will allow requests to be made to localhost from any origin.- Parameters:
localhostPassThrough
- True if localhost pass-through is enabled- Since:
- 3.8.5
-
setConfigurations
Sets the CORS configurations.- Parameters:
configurations
- The CORS configurations
-
setSingleHeader
public void setSingleHeader(boolean singleHeader) Sets whether CORS header values should be joined into a single header. Default value (false).- Parameters:
singleHeader
- The single header flag
-