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 Details

    • Builder

      public Builder()
  • Method Details

    • allowOrigins

      @Stability(Stable) public CorsOptions.Builder allowOrigins(List<String> allowOrigins)
      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, specify Cors.ALL_ORIGINS or [ * ].

      Responses will include the Access-Control-Allow-Origin response header. If Cors.ALL_ORIGINS is specified, the Vary: Origin response header will also be included.

      Returns:
      this
    • allowCredentials

      @Stability(Stable) public CorsOptions.Builder allowCredentials(Boolean allowCredentials)
      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

      @Stability(Stable) public CorsOptions.Builder allowHeaders(List<String> allowHeaders)
      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

      @Stability(Stable) public CorsOptions.Builder allowMethods(List<String> allowMethods)
      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. If ANY is specified, it will be expanded to Cors.ALL_METHODS.
      Returns:
      this
    • disableCache

      @Stability(Stable) public CorsOptions.Builder disableCache(Boolean disableCache)
      Parameters:
      disableCache - Sets Access-Control-Max-Age to -1, which means that caching is disabled. This option cannot be used with maxAge.
      Returns:
      this
    • exposeHeaders

      @Stability(Stable) public CorsOptions.Builder exposeHeaders(List<String> exposeHeaders)
      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

      @Stability(Stable) public CorsOptions.Builder maxAge(Duration maxAge)
      Sets the value of CorsOptions.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 use disableCache: true.
      Returns:
      this
    • statusCode

      @Stability(Stable) public CorsOptions.Builder statusCode(Number statusCode)
      Sets the value of CorsOptions.getStatusCode()
      Parameters:
      statusCode - Specifies the response status code returned from the OPTIONS method.
      Returns:
      this
    • build

      @Stability(Stable) public CorsOptions build()
      Builds the configured instance.
      Specified by:
      build in interface software.amazon.jsii.Builder<CorsOptions>
      Returns:
      a new instance of CorsOptions
      Throws:
      NullPointerException - if any required attribute was not provided