Class CorsOriginConfiguration

java.lang.Object
io.micronaut.http.server.cors.CorsOriginConfiguration

public class CorsOriginConfiguration extends Object
Stores configuration for CORS.
Since:
1.0
Author:
James Kleeh, Graeme Rocher
  • Field Details

    • ANY

      public static final List<String> ANY
      Constant to represent any value.
    • ANY_METHOD

      public static final List<HttpMethod> ANY_METHOD
      Constant to represent any method.
    • DEFAULT_ALLOW_PRIVATE_NETWORK

      public static final boolean DEFAULT_ALLOW_PRIVATE_NETWORK
      Default value for allow private network.
      See Also:
  • Constructor Details

    • CorsOriginConfiguration

      public CorsOriginConfiguration()
  • Method Details

    • getAllowedOrigins

      public List<String> getAllowedOrigins()
      Returns:
      The allowed origins
    • setAllowedOrigins

      public void setAllowedOrigins(@Nullable @Nullable List<String> allowedOrigins)
      Sets the allowed origins.
      Parameters:
      allowedOrigins - The allow origins
    • getAllowedOriginsRegex

      @NonNull public @NonNull Optional<String> getAllowedOriginsRegex()
      Returns:
      a regular expression for matching Allowed Origins.
    • setAllowedOriginsRegex

      public void setAllowedOriginsRegex(String allowedOriginsRegex)
      Sets a regular expression for matching Allowed Origins.
      Parameters:
      allowedOriginsRegex - a regular expression for matching Allowed Origins.
    • getAllowedMethods

      public List<HttpMethod> getAllowedMethods()
      Returns:
      The allowed methods
    • setAllowedMethods

      public void setAllowedMethods(@Nullable @Nullable List<HttpMethod> allowedMethods)
      Sets the allowed methods.
      Parameters:
      allowedMethods - The allowed methods
    • getAllowedHeaders

      public List<String> getAllowedHeaders()
      Returns:
      The allowed headers
    • setAllowedHeaders

      public void setAllowedHeaders(@Nullable @Nullable List<String> allowedHeaders)
      Sets the allowed headers.
      Parameters:
      allowedHeaders - The allowed headers
    • getExposedHeaders

      public List<String> getExposedHeaders()
      Returns:
      The exposed headers
    • setExposedHeaders

      public void setExposedHeaders(@Nullable @Nullable List<String> exposedHeaders)
      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

      public Long getMaxAge()
      Returns:
      The max age. A value of -1 indicates no max age
    • setMaxAge

      public void setMaxAge(@Nullable @Nullable Long maxAge)
      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