java.lang.Object
io.helidon.webserver.cors.CrossOriginConfig
Represents information about cross origin request sharing.
Applications can obtain a new instance in three ways:
- Use a
Builder
explicitly.Obtain a suitable builder by:
- getting a new builder using the static
builder()
method, - initializing a builder from an existing
CrossOriginConfig
instance using the staticbuilder(CrossOriginConfig)
method, or - initializing a builder from a
Config
node, invokingConfig.as(io.helidon.common.GenericType<T>)
usingcorsConfig.as(CrossOriginConfig::builder).get()
build
method to create the instance. - getting a new builder using the static
- Invoke the static
create(Config)
method, passing a config node containing the cross-origin information to be converted. This is a convenience method equivalent to creating a builder using the config node and then invokingbuild()
. - Invoke the static
create()
method which returns aCrossOriginConfig
instance which implements the default CORS behavior.
- See Also:
-
Nested Class Summary
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
Header Access-Control-Allow-Credentials.static final String
Header Access-Control-Allow-Headers.static final String
Header Access-Control-Allow-Methods.static final String
Header Access-Control-Allow-Origin.static final String
Header Access-Control-Expose-Headers.static final String
Header Access-Control-Max-Age.static final String
Header Access-Control-Request-Headers.static final String
Header Access-Control-Request-Method.static final String
Key for the node within the CORS config that contains the list of path information.static final long
Default cache expiration in seconds. -
Method Summary
Modifier and TypeMethodDescriptionboolean
String[]
String[]
String[]
static CrossOriginConfig.Builder
builder()
static CrossOriginConfig.Builder
Creates a newCrossOriginConfig.Builder
using the provided config node.static CrossOriginConfig.Builder
builder
(CrossOriginConfig original) Initializes a newCrossOriginConfig.Builder
from the values in an existingCrossOriginConfig
object.static CrossOriginConfig
create()
Creates a newCrossOriginConfig
instance which represents the default CORS behavior.static CrossOriginConfig
Creates a newCrossOriginConfig
instance based on the provided configuration node.String[]
boolean
boolean
Reports whether the specified HTTP method name matches thisCrossOriginConfig
.long
toString()
-
Field Details
-
CORS_PATHS_CONFIG_KEY
Key for the node within the CORS config that contains the list of path information.- See Also:
-
ACCESS_CONTROL_ALLOW_HEADERS
Header Access-Control-Allow-Headers.- See Also:
-
ACCESS_CONTROL_ALLOW_METHODS
Header Access-Control-Allow-Methods.- See Also:
-
ACCESS_CONTROL_ALLOW_CREDENTIALS
Header Access-Control-Allow-Credentials.- See Also:
-
ACCESS_CONTROL_MAX_AGE
Header Access-Control-Max-Age.- See Also:
-
ACCESS_CONTROL_EXPOSE_HEADERS
Header Access-Control-Expose-Headers.- See Also:
-
ACCESS_CONTROL_ALLOW_ORIGIN
Header Access-Control-Allow-Origin.- See Also:
-
ACCESS_CONTROL_REQUEST_HEADERS
Header Access-Control-Request-Headers.- See Also:
-
ACCESS_CONTROL_REQUEST_METHOD
Header Access-Control-Request-Method.- See Also:
-
DEFAULT_AGE
public static final long DEFAULT_AGEDefault cache expiration in seconds.- See Also:
-
-
Method Details
-
builder
- Returns:
- a new builder for basic cross origin config
-
builder
Creates a newCrossOriginConfig.Builder
using the provided config node.Although this method is equivalent to
builder().config(config)
it conveniently combines those two steps for use as a method reference.- Parameters:
config
- node containing cross-origin information- Returns:
- new
CrossOriginConfig.Builder
instance based on the configuration
-
builder
Initializes a newCrossOriginConfig.Builder
from the values in an existingCrossOriginConfig
object.- Parameters:
original
- the existing cross-origin config object- Returns:
- new Builder initialized from the existing object's settings
-
create
Creates a newCrossOriginConfig
instance which represents the default CORS behavior.- Returns:
- new default
CrossOriginConfig
instance
-
create
Creates a newCrossOriginConfig
instance based on the provided configuration node.- Parameters:
corsConfig
- node containing CORS information- Returns:
- new
CrossOriginConfig
based on the configuration
-
pathPattern
- Returns:
- the configured path expression; defaults to a "match-everything" pattern
-
isEnabled
public boolean isEnabled()- Returns:
- whether this cross-origin config is enabled
-
allowOrigins
- Returns:
- the allowed origins
-
allowHeaders
- Returns:
- the allowed headers
-
exposeHeaders
- Returns:
- headers OK to expose in responses
-
allowMethods
- Returns:
- allowed methods
-
allowCredentials
public boolean allowCredentials()- Returns:
- allowed credentials
-
maxAgeSeconds
public long maxAgeSeconds()- Returns:
- maximum age
-
matches
Reports whether the specified HTTP method name matches thisCrossOriginConfig
.- Parameters:
method
- HTTP method name to check- Returns:
- true if this
CrossOriginConfig
matches the specified method; false otherwise
-
toString
-