Class CorsSettings
java.lang.Object
org.apache.pekko.http.cors.javadsl.settings.CorsSettings
org.apache.pekko.http.cors.scaladsl.settings.CorsSettings
- Direct Known Subclasses:
CorsSettingsImpl
Settings used by the CORS directives.
Public API but not intended for subclassing.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract scala.collection.immutable.List<HttpHeader>actualResponseHeaders(scala.collection.immutable.Seq<HttpOrigin> origins) abstract booleanIndicates whether the resource supports user credentials.abstract HttpHeaderRangeList of request headers that can be used when making an actual request.abstract scala.collection.immutable.Seq<HttpMethod>List of methods that can be used when making an actual request.abstract HttpOriginMatcherList of origins that the CORS filter must allow.abstract booleanIftrue, allow generic requests (that are outside the scope of the specification) to pass through the directive.static Tapply(com.typesafe.config.Config config) static Tstatic Tapply(org.apache.pekko.actor.ActorSystem system) abstract scala.collection.immutable.Seq<String>List of headers (other than simple response headers) that browsers are allowed to access.static CorsSettingsfromSubConfig(com.typesafe.config.Config root, com.typesafe.config.Config config) booleanbooleanabstract scala.Option<Object>maxAge()When set, the amount of seconds the browser is allowed to cache the results of a preflight request.protected static Stringprefix()abstract scala.collection.immutable.List<HttpHeader>preflightResponseHeaders(scala.collection.immutable.Seq<HttpOrigin> origins, scala.collection.immutable.Seq<String> requestHeaders) withAllowCredentials(boolean newValue) withAllowedHeaders(HttpHeaderRange newValue) withAllowedHeaders(HttpHeaderRange newValue) withAllowedMethods(Iterable<HttpMethod> newValue) withAllowedMethods(scala.collection.immutable.Seq<HttpMethod> newValue) withAllowedOrigins(HttpOriginMatcher newValue) withAllowedOrigins(HttpOriginMatcher newValue) withAllowGenericHttpRequests(boolean newValue) withExposedHeaders(Iterable<String> newValue) withExposedHeaders(scala.collection.immutable.Seq<String> newValue) withMaxAge(OptionalLong newValue) withMaxAge(scala.Option<Object> newValue) Methods inherited from class org.apache.pekko.http.cors.javadsl.settings.CorsSettings
create, create, create
-
Constructor Details
-
CorsSettings
public CorsSettings()
-
-
Method Details
-
fromSubConfig
public static CorsSettings fromSubConfig(com.typesafe.config.Config root, com.typesafe.config.Config config) -
prefix
-
apply
public static T apply(org.apache.pekko.actor.ActorSystem system) -
apply
-
apply
public static T apply(com.typesafe.config.Config config) -
allowGenericHttpRequests
public abstract boolean allowGenericHttpRequests()Iftrue, allow generic requests (that are outside the scope of the specification) to pass through the directive. Else, strict CORS filtering is applied and any invalid request will be rejected.Default:
true- Returns:
- (undocumented)
-
allowCredentials
public abstract boolean allowCredentials()Indicates whether the resource supports user credentials. Iftrue, the headerAccess-Control-Allow-Credentialsis set in the response, indicating that the actual request can include user credentials. Examples of user credentials are: cookies, HTTP authentication or client-side certificates.Default:
true- Returns:
- (undocumented)
-
allowedOrigins
List of origins that the CORS filter must allow. Can also be set to*to allow access to the resource from any origin. Controls the content of theAccess-Control-Allow-Originresponse header: if parameter is*and credentials are not allowed, a*is set inAccess-Control-Allow-Origin. Otherwise, the origins given in theOriginrequest header are echoed.Hostname starting with
*.will match any sub-domain. The scheme and the port are always strictly matched.The actual or preflight request is rejected if any of the origins from the request is not allowed.
Default:
HttpOriginMatcher.*- Returns:
- (undocumented)
-
allowedHeaders
List of request headers that can be used when making an actual request. Controls the content of theAccess-Control-Allow-Headersheader in a preflight response: if parameter is*, the headers fromAccess-Control-Request-Headersare echoed. Otherwise the parameter list is returned as part of the header.Default:
HttpHeaderRange.*- Returns:
- (undocumented)
-
allowedMethods
List of methods that can be used when making an actual request. The list is returned as part of theAccess-Control-Allow-Methodspreflight response header.The preflight request will be rejected if the
Access-Control-Request-Methodheader's method is not part of the list.Default:
Seq(GET, POST, HEAD, OPTIONS)- Returns:
- (undocumented)
-
exposedHeaders
List of headers (other than simple response headers) that browsers are allowed to access. If not empty, this list is returned as part of theAccess-Control-Expose-Headersheader in the actual response.Default:
Seq.empty- Returns:
- (undocumented)
-
maxAge
When set, the amount of seconds the browser is allowed to cache the results of a preflight request. This value is returned as part of theAccess-Control-Max-Agepreflight response header. IfNone, the header is not added to the preflight response.Default:
Some(30 * 60)- Returns:
- (undocumented)
-
getAllowGenericHttpRequests
public boolean getAllowGenericHttpRequests()- Specified by:
getAllowGenericHttpRequestsin classCorsSettings
-
getAllowCredentials
public boolean getAllowCredentials()- Specified by:
getAllowCredentialsin classCorsSettings
-
getAllowedOrigins
- Specified by:
getAllowedOriginsin classCorsSettings
-
getAllowedHeaders
- Specified by:
getAllowedHeadersin classCorsSettings
-
getAllowedMethods
- Specified by:
getAllowedMethodsin classCorsSettings
-
getExposedHeaders
- Specified by:
getExposedHeadersin classCorsSettings
-
getMaxAge
- Specified by:
getMaxAgein classCorsSettings
-
withAllowGenericHttpRequests
- Specified by:
withAllowGenericHttpRequestsin classCorsSettings
-
withAllowCredentials
- Specified by:
withAllowCredentialsin classCorsSettings
-
withAllowedOrigins
- Specified by:
withAllowedOriginsin classCorsSettings
-
withAllowedHeaders
- Specified by:
withAllowedHeadersin classCorsSettings
-
withAllowedMethods
- Specified by:
withAllowedMethodsin classCorsSettings
-
withExposedHeaders
- Specified by:
withExposedHeadersin classCorsSettings
-
withMaxAge
- Specified by:
withMaxAgein classCorsSettings
-
withAllowedOrigins
-
withAllowedHeaders
-
withAllowedMethods
-
withExposedHeaders
-
withMaxAge
-
preflightResponseHeaders
public abstract scala.collection.immutable.List<HttpHeader> preflightResponseHeaders(scala.collection.immutable.Seq<HttpOrigin> origins, scala.collection.immutable.Seq<String> requestHeaders) -
actualResponseHeaders
public abstract scala.collection.immutable.List<HttpHeader> actualResponseHeaders(scala.collection.immutable.Seq<HttpOrigin> origins)
-