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
Modifier and TypeFieldDescriptionConstant to represent any value.static final List<HttpMethod>
Constant to represent any method.static final boolean
Default value for allow private network. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
boolean
void
setAllowCredentials
(boolean allowCredentials) Sets whether to allow credentials.void
setAllowedHeaders
(@Nullable List<String> allowedHeaders) Sets the allowed headers.void
setAllowedMethods
(@Nullable List<HttpMethod> allowedMethods) Sets the allowed methods.void
setAllowedOrigins
(@Nullable List<String> allowedOrigins) Sets the allowed origins.void
setAllowedOriginsRegex
(String allowedOriginsRegex) Sets a regular expression for matching Allowed Origins.void
setAllowPrivateNetwork
(boolean allowPrivateNetwork) Sets whether to allow private network.void
setExposedHeaders
(@Nullable List<String> exposedHeaders) Sets the exposed headers.void
Sets 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
-