Class CorsOptions.Builder
java.lang.Object
software.amazon.awscdk.services.apigateway.CorsOptions.Builder
- All Implemented Interfaces:
software.amazon.jsii.Builder<CorsOptions>
- Enclosing interface:
CorsOptions
@Stability(Stable)
public static final class CorsOptions.Builder
extends Object
implements software.amazon.jsii.Builder<CorsOptions>
A builder for
CorsOptions
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionallowCredentials
(Boolean allowCredentials) Sets the value ofCorsOptions.getAllowCredentials()
allowHeaders
(List<String> allowHeaders) Sets the value ofCorsOptions.getAllowHeaders()
allowMethods
(List<String> allowMethods) Sets the value ofCorsOptions.getAllowMethods()
allowOrigins
(List<String> allowOrigins) Sets the value ofCorsOptions.getAllowOrigins()
build()
Builds the configured instance.disableCache
(Boolean disableCache) Sets the value ofCorsOptions.getDisableCache()
exposeHeaders
(List<String> exposeHeaders) Sets the value ofCorsOptions.getExposeHeaders()
Sets the value ofCorsOptions.getMaxAge()
statusCode
(Number statusCode) Sets the value ofCorsOptions.getStatusCode()
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
allowOrigins
Sets the value ofCorsOptions.getAllowOrigins()
- Parameters:
allowOrigins
- Specifies the list of origins that are allowed to make requests to this resource. This parameter is required. If you wish to allow all origins, specifyCors.ALL_ORIGINS
or[ * ]
.Responses will include the
Access-Control-Allow-Origin
response header. IfCors.ALL_ORIGINS
is specified, theVary: Origin
response header will also be included.- Returns:
this
-
allowCredentials
Sets the value ofCorsOptions.getAllowCredentials()
- Parameters:
allowCredentials
- The Access-Control-Allow-Credentials response header tells browsers whether to expose the response to frontend JavaScript code when the request's credentials mode (Request.credentials) is "include". When a request's credentials mode (Request.credentials) is "include", browsers will only expose the response to frontend JavaScript code if the Access-Control-Allow-Credentials value is true.Credentials are cookies, authorization headers or TLS client certificates.
- Returns:
this
-
allowHeaders
Sets the value ofCorsOptions.getAllowHeaders()
- Parameters:
allowHeaders
- The Access-Control-Allow-Headers response header is used in response to a preflight request which includes the Access-Control-Request-Headers to indicate which HTTP headers can be used during the actual request.- Returns:
this
-
allowMethods
Sets the value ofCorsOptions.getAllowMethods()
- Parameters:
allowMethods
- The Access-Control-Allow-Methods response header specifies the method or methods allowed when accessing the resource in response to a preflight request. IfANY
is specified, it will be expanded toCors.ALL_METHODS
.- Returns:
this
-
disableCache
Sets the value ofCorsOptions.getDisableCache()
- Parameters:
disableCache
- Sets Access-Control-Max-Age to -1, which means that caching is disabled. This option cannot be used withmaxAge
.- Returns:
this
-
exposeHeaders
Sets the value ofCorsOptions.getExposeHeaders()
- Parameters:
exposeHeaders
- The Access-Control-Expose-Headers response header indicates which headers can be exposed as part of the response by listing their names. If you want clients to be able to access other headers, you have to list them using the Access-Control-Expose-Headers header.- Returns:
this
-
maxAge
Sets the value ofCorsOptions.getMaxAge()
- Parameters:
maxAge
- The Access-Control-Max-Age response header indicates how long the results of a preflight request (that is the information contained in the Access-Control-Allow-Methods and Access-Control-Allow-Headers headers) can be cached. To disable caching altogether usedisableCache: true
.- Returns:
this
-
statusCode
Sets the value ofCorsOptions.getStatusCode()
- Parameters:
statusCode
- Specifies the response status code returned from the OPTIONS method.- Returns:
this
-
build
Builds the configured instance.- Specified by:
build
in interfacesoftware.amazon.jsii.Builder<CorsOptions>
- Returns:
- a new instance of
CorsOptions
- Throws:
NullPointerException
- if any required attribute was not provided
-