@Provider public class CrossOriginResourceSharingFilter extends Object implements ContainerResponseFilter
ContainerResponseFilter that adds CORS-related headers to HTTP responses.| Modifier and Type | Field and Description |
|---|---|
static String |
CONFIG_HTTP_CORS_ALLOW_CREDENTIALS
The configuration key controlling the CORS -Allow-Credentials header.
|
static String |
CONFIG_HTTP_CORS_ALLOW_HEADERS
The configuration key controlling the CORS -Allow-Headers header.
|
static String |
CONFIG_HTTP_CORS_ALLOW_METHODS
The configuration key controlling the CORS -Allow-Methods header.
|
static String |
CONFIG_HTTP_CORS_ALLOW_ORIGIN
The configuration key controlling the CORS -Allow-Origin header.
|
static String |
CONFIG_HTTP_CORS_EXPOSE_HEADERS
The configuration key controlling the CORS -Expose-Headers header.
|
static String |
CONFIG_HTTP_CORS_MAX_AGE
The configuration key controlling the CORS -Max-Age header.
|
| Constructor and Description |
|---|
CrossOriginResourceSharingFilter()
Create a CORS filter with default values.
|
CrossOriginResourceSharingFilter(Collection<String> origins,
Collection<String> allowedMethods,
Collection<String> allowedHeaders,
Collection<String> exposedHeaders,
boolean credentials,
int cacheSeconds)
Create a CORS filter.
|
| Modifier and Type | Method and Description |
|---|---|
void |
filter(ContainerRequestContext req,
ContainerResponseContext res) |
public static final String CONFIG_HTTP_CORS_ALLOW_ORIGIN
public static final String CONFIG_HTTP_CORS_ALLOW_METHODS
public static final String CONFIG_HTTP_CORS_ALLOW_HEADERS
public static final String CONFIG_HTTP_CORS_EXPOSE_HEADERS
public static final String CONFIG_HTTP_CORS_ALLOW_CREDENTIALS
public static final String CONFIG_HTTP_CORS_MAX_AGE
@Inject public CrossOriginResourceSharingFilter()
public CrossOriginResourceSharingFilter(Collection<String> origins, Collection<String> allowedMethods, Collection<String> allowedHeaders, Collection<String> exposedHeaders, boolean credentials, int cacheSeconds)
origins - a collection of allowed origin valuesallowedMethods - a collection of allowed methodsallowedHeaders - a collection of allowed headersexposedHeaders - a collection of exposed headerscredentials - true if the Access-Control-Allow-Credentials header is to be setcacheSeconds - set this to a value greater than zero to set the Access-Control-Max-Age headerpublic void filter(ContainerRequestContext req, ContainerResponseContext res)
filter in interface ContainerResponseFilter