Package io.micronaut.http.server.cors
Class CorsOriginConfiguration
java.lang.Object
io.micronaut.http.server.cors.CorsOriginConfiguration
Stores configuration for CORS.
- Since:
- 1.0
- Author:
- James Kleeh, Graeme Rocher
-
Field Summary
FieldsModifier and TypeFieldDescriptionConstant to represent any value.static final List<HttpMethod>Constant to represent any method.static final booleanDefault value for allow private network. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanbooleanvoidsetAllowCredentials(boolean allowCredentials) Sets whether to allow credentials.voidsetAllowedHeaders(@Nullable List<String> allowedHeaders) Sets the allowed headers.voidsetAllowedMethods(@Nullable List<HttpMethod> allowedMethods) Sets the allowed methods.voidsetAllowedOrigins(@Nullable List<String> allowedOrigins) Sets the allowed origins.voidsetAllowedOriginsRegex(String allowedOriginsRegex) Sets a regular expression for matching Allowed Origins.voidsetAllowPrivateNetwork(boolean allowPrivateNetwork) Sets whether to allow private network.voidsetExposedHeaders(@Nullable List<String> exposedHeaders) Sets the exposed headers.voidSets the max age.
-
Field Details
-
ANY
Constant to represent any value. -
ANY_METHOD
Constant to represent any method. -
DEFAULT_ALLOW_PRIVATE_NETWORK
public static final boolean DEFAULT_ALLOW_PRIVATE_NETWORKDefault value for allow private network.- See Also:
-
-
Constructor Details
-
CorsOriginConfiguration
public CorsOriginConfiguration()
-
-
Method Details
-
getAllowedOrigins
- Returns:
- The allowed origins
-
setAllowedOrigins
Sets the allowed origins.- Parameters:
allowedOrigins- The allow origins
-
getAllowedOriginsRegex
- Returns:
- a regular expression for matching Allowed Origins.
-
setAllowedOriginsRegex
Sets a regular expression for matching Allowed Origins.- Parameters:
allowedOriginsRegex- a regular expression for matching Allowed Origins.
-
getAllowedMethods
- Returns:
- The allowed methods
-
setAllowedMethods
Sets the allowed methods.- Parameters:
allowedMethods- The allowed methods
-
getAllowedHeaders
- Returns:
- The allowed headers
-
setAllowedHeaders
Sets the allowed headers.- Parameters:
allowedHeaders- The allowed headers
-
getExposedHeaders
- Returns:
- The exposed headers
-
setExposedHeaders
Sets the exposed headers.- Parameters:
exposedHeaders- The exposed headers
-
isAllowCredentials
public boolean isAllowCredentials()- Returns:
- Whether to allow credentials
-
setAllowCredentials
public void setAllowCredentials(boolean allowCredentials) Sets whether to allow credentials.- Parameters:
allowCredentials- The credentials
-
getMaxAge
- Returns:
- The max age. A value of -1 indicates no max age
-
setMaxAge
Sets the max age.- Parameters:
maxAge- The max age
-
isAllowPrivateNetwork
public boolean isAllowPrivateNetwork()- Returns:
- Whether to allow private network
- Since:
- 4.3.0
-
setAllowPrivateNetwork
public void setAllowPrivateNetwork(boolean allowPrivateNetwork) Sets whether to allow private network. Defaults to#DEFAULT_ALLOW_PRIVATE_NETWORK.- Parameters:
allowPrivateNetwork- Allow private network- Since:
- 4.3.0
-