- java.lang.Object
-
- io.helidon.webserver.cors.CorsEnabledServiceHelper
-
public class CorsEnabledServiceHelper extends Object
Allows services (including Helidon built-in services) to register CORS support easily.Callers use either
create(String)orcreate(String, CrossOriginConfig)to initialize the helper for a service. The helper uses theCrossOriginConfiginstance to set up CORS behavior for the service. If the caller passes a nullCrossOriginConfigor invokes the other variant ofcreatethen the sets up CORS using a default configuration:enabled: true allow-origins: ["*"] allow-methods: ["GET", "HEAD", "OPTIONS"] allow-headers: ["*"] allow-credentials: false max-age: 3600All of those settings except forallow-methodsare the defaults forCrossOriginConfig.
-
-
Field Summary
Fields Modifier and Type Field Description static StringCORS_CONFIG_KEYConventional configuration key for CORS set-up; used for built-in services.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static CorsEnabledServiceHelpercreate(String serviceName)Creates a new helper based on a default CORS config for services.static CorsEnabledServiceHelpercreate(String serviceName, CrossOriginConfig crossOriginConfig)Creates a new helper based on the provided config.Handlerprocessor()
-
-
-
Field Detail
-
CORS_CONFIG_KEY
public static final String CORS_CONFIG_KEY
Conventional configuration key for CORS set-up; used for built-in services.- See Also:
- Constant Field Values
-
-
Method Detail
-
create
public static CorsEnabledServiceHelper create(String serviceName, CrossOriginConfig crossOriginConfig)
Creates a new helper based on the provided config.- Parameters:
serviceName- name of the service (for logging)crossOriginConfig-CrossOriginConfigcontaining CORS set-up; if null, a default is used- Returns:
- new helper initialized with the CORS configuration
-
create
public static CorsEnabledServiceHelper create(String serviceName)
Creates a new helper based on a default CORS config for services.- Parameters:
serviceName- name of the service (for logging)- Returns:
- new helper initialized with a default CORS configuration
-
processor
public Handler processor()
- Returns:
Handlerfor CORS processing
-
-