/*
* Copyright 2014 Red Hat, Inc.
*
* Red Hat licenses this file to you under the Apache License, version 2.0
* (the "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/
package io.vertx.reactivex.ext.web.handler;
import java.util.Map;
import io.reactivex.Observable;
import io.reactivex.Flowable;
import io.reactivex.Single;
import io.reactivex.Completable;
import io.reactivex.Maybe;
import io.vertx.core.http.HttpMethod;
import java.util.Set;
import io.vertx.core.Handler;
A handler which implements server side http://www.w3.org/TR/cors/[CORS] support for Vert.x-Web.
NOTE: This class has been automatically generated from the original
non RX-ified interface using Vert.x codegen. /**
* A handler which implements server side http://www.w3.org/TR/cors/[CORS] support for Vert.x-Web.
*
* <p/>
* NOTE: This class has been automatically generated from the {@link io.vertx.ext.web.handler.CorsHandler original} non RX-ified interface using Vert.x codegen.
*/
@io.vertx.lang.rx.RxGen(io.vertx.ext.web.handler.CorsHandler.class)
public class CorsHandler implements io.vertx.core.Handler<io.vertx.reactivex.ext.web.RoutingContext> {
@Override
public String toString() {
return delegate.toString();
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
CorsHandler that = (CorsHandler) o;
return delegate.equals(that.delegate);
}
@Override
public int hashCode() {
return delegate.hashCode();
}
public static final io.vertx.lang.rx.TypeArg<CorsHandler> __TYPE_ARG = new io.vertx.lang.rx.TypeArg<>( obj -> new CorsHandler((io.vertx.ext.web.handler.CorsHandler) obj),
CorsHandler::getDelegate
);
private final io.vertx.ext.web.handler.CorsHandler delegate;
public CorsHandler(io.vertx.ext.web.handler.CorsHandler delegate) {
this.delegate = delegate;
}
public io.vertx.ext.web.handler.CorsHandler getDelegate() {
return delegate;
}
Something has happened, so handle it.
Params: - event – the event to handle
/**
* Something has happened, so handle it.
* @param event the event to handle
*/
public void handle(io.vertx.reactivex.ext.web.RoutingContext event) {
delegate.handle(event.getDelegate());
}
Create a CORS handler
Params: - allowedOriginPattern – the allowed origin pattern
Returns: the handler
/**
* Create a CORS handler
* @param allowedOriginPattern the allowed origin pattern
* @return the handler
*/
public static io.vertx.reactivex.ext.web.handler.CorsHandler create(String allowedOriginPattern) {
io.vertx.reactivex.ext.web.handler.CorsHandler ret = io.vertx.reactivex.ext.web.handler.CorsHandler.newInstance(io.vertx.ext.web.handler.CorsHandler.create(allowedOriginPattern));
return ret;
}
Add an allowed method
Params: - method – the method to add
Returns: a reference to this, so the API can be used fluently
/**
* Add an allowed method
* @param method the method to add
* @return a reference to this, so the API can be used fluently
*/
public io.vertx.reactivex.ext.web.handler.CorsHandler allowedMethod(HttpMethod method) {
delegate.allowedMethod(method);
return this;
}
Add a set of allowed methods
Params: - methods – the methods to add
Returns: a reference to this, so the API can be used fluently
/**
* Add a set of allowed methods
* @param methods the methods to add
* @return a reference to this, so the API can be used fluently
*/
public io.vertx.reactivex.ext.web.handler.CorsHandler allowedMethods(Set<HttpMethod> methods) {
delegate.allowedMethods(methods);
return this;
}
Add an allowed header
Params: - headerName – the allowed header name
Returns: a reference to this, so the API can be used fluently
/**
* Add an allowed header
* @param headerName the allowed header name
* @return a reference to this, so the API can be used fluently
*/
public io.vertx.reactivex.ext.web.handler.CorsHandler allowedHeader(String headerName) {
delegate.allowedHeader(headerName);
return this;
}
Add a set of allowed headers
Params: - headerNames – the allowed header names
Returns: a reference to this, so the API can be used fluently
/**
* Add a set of allowed headers
* @param headerNames the allowed header names
* @return a reference to this, so the API can be used fluently
*/
public io.vertx.reactivex.ext.web.handler.CorsHandler allowedHeaders(Set<String> headerNames) {
delegate.allowedHeaders(headerNames);
return this;
}
Add an exposed header
Params: - headerName – the exposed header name
Returns: a reference to this, so the API can be used fluently
/**
* Add an exposed header
* @param headerName the exposed header name
* @return a reference to this, so the API can be used fluently
*/
public io.vertx.reactivex.ext.web.handler.CorsHandler exposedHeader(String headerName) {
delegate.exposedHeader(headerName);
return this;
}
Add a set of exposed headers
Params: - headerNames – the exposed header names
Returns: a reference to this, so the API can be used fluently
/**
* Add a set of exposed headers
* @param headerNames the exposed header names
* @return a reference to this, so the API can be used fluently
*/
public io.vertx.reactivex.ext.web.handler.CorsHandler exposedHeaders(Set<String> headerNames) {
delegate.exposedHeaders(headerNames);
return this;
}
Set whether credentials are allowed. Note that user agents will block
requests that use a wildcard as origin and include credentials.
From the MDN documentation you can read:
Important note: when responding to a credentialed request,
server must specify a domain, and cannot use wild carding.
Params: - allow – true if allowed
Returns: a reference to this, so the API can be used fluently
/**
* Set whether credentials are allowed. Note that user agents will block
* requests that use a wildcard as origin and include credentials.
*
* From the MDN documentation you can read:
*
* <blockquote>
* Important note: when responding to a credentialed request,
* server must specify a domain, and cannot use wild carding.
* </blockquote>
* @param allow true if allowed
* @return a reference to this, so the API can be used fluently
*/
public io.vertx.reactivex.ext.web.handler.CorsHandler allowCredentials(boolean allow) {
delegate.allowCredentials(allow);
return this;
}
Set how long the browser should cache the information
Params: - maxAgeSeconds – max age in seconds
Returns: a reference to this, so the API can be used fluently
/**
* Set how long the browser should cache the information
* @param maxAgeSeconds max age in seconds
* @return a reference to this, so the API can be used fluently
*/
public io.vertx.reactivex.ext.web.handler.CorsHandler maxAgeSeconds(int maxAgeSeconds) {
delegate.maxAgeSeconds(maxAgeSeconds);
return this;
}
public static CorsHandler newInstance(io.vertx.ext.web.handler.CorsHandler arg) {
return arg != null ? new CorsHandler(arg) : null;
}
}