Package io.vertx.reactivex.ext.web.handler

## Class CorsHandler

- java.lang.Object
- - io.vertx.reactivex.ext.web.handler.CorsHandler

- All Implemented Interfaces:
    `Handler<RoutingContext>`, `SecurityPolicyHandler`

      public class CorsHandler
      extends Object
      implements SecurityPolicyHandler, Handler<RoutingContext>

  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.

- - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `static io.vertx.lang.rx.TypeArg<CorsHandler>` | `__TYPE_ARG` |

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `CorsHandler​(CorsHandler delegate)` |
    `CorsHandler​(Object delegate)` |

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `CorsHandler` | `addOrigin​(String origin)` | Add an origin to the list of allowed Origins.
    `CorsHandler` | `addOrigins​(List<String> origins)` | Set the list of allowed origins.
    `CorsHandler` | `addRelativeOrigin​(String origin)` | Add a relative origin to the list of allowed Origins.
    `CorsHandler` | `addRelativeOrigins​(List<String> origins)` | Set the list of allowed relative origins.
    `CorsHandler` | `allowCredentials​(boolean allow)` | Set whether credentials are allowed.
    `CorsHandler` | `allowedHeader​(String headerName)` | Add an allowed header
    `CorsHandler` | `allowedHeaders​(Set<String> headerNames)` | Add a set of allowed headers
    `CorsHandler` | `allowedMethod​(HttpMethod method)` | Add an allowed method
    `CorsHandler` | `allowedMethods​(Set<HttpMethod> methods)` | Add a set of allowed methods
    `CorsHandler` | `allowPrivateNetwork​(boolean allow)` | Set whether access from public to private networks are allowed.
    `static CorsHandler` | `create()` | Create a empty CORS handler that allows `*` origin.
    `boolean` | `equals​(Object o)` |
    `CorsHandler` | `exposedHeader​(String headerName)` | Add an exposed header
    `CorsHandler` | `exposedHeaders​(Set<String> headerNames)` | Add a set of exposed headers
    `CorsHandler` | `getDelegate()` |
    `void` | `handle​(RoutingContext event)` | Something has happened, so handle it.
    `int` | `hashCode()` |
    `CorsHandler` | `maxAgeSeconds​(int maxAgeSeconds)` | Set how long the browser should cache the information
    `static CorsHandler` | `newInstance​(CorsHandler arg)` |
    `String` | `toString()` |

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### __TYPE_ARG

          public static final io.vertx.lang.rx.TypeArg<CorsHandler> __TYPE_ARG

  - ### Constructor Detail

    - #### CorsHandler

          public CorsHandler​(CorsHandler delegate)

    - #### CorsHandler

          public CorsHandler​(Object delegate)

  - ### Method Detail

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

    - #### equals

          public boolean equals​(Object o)

      Overrides:
        `equals` in class `Object`

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `Object`

    - #### getDelegate

          public CorsHandler getDelegate()

      Specified by:
        `getDelegate` in interface `SecurityPolicyHandler`

    - #### handle

          public void handle​(RoutingContext event)

      Something has happened, so handle it.
      Specified by:
        `handle` in interface `Handler<RoutingContext>`
      Specified by:
        `handle` in interface `SecurityPolicyHandler`
      Parameters:
        `event` - the event to handle

    - #### create

          public static CorsHandler create()

      Create a empty CORS handler that allows `*` origin.
      Returns:
        the handler

    - #### addOrigin

          public CorsHandler addOrigin​(String origin)

      Add an origin to the list of allowed Origins. An origin follows rfc6454#section-7 and is expected to have the format: `"://" [ ":" ]`
      Parameters:
        `origin` - the well formatted static origin
      Returns:
        self

    - #### addRelativeOrigins

          public CorsHandler addRelativeOrigins​(List<String> origins)

      Set the list of allowed relative origins. A relative origin is a regex that should match the format `"://" [ ":" ]`.
      Parameters:
        `origins` - the well formatted relative origin list
      Returns:
        self

    - #### addRelativeOrigin

          public CorsHandler addRelativeOrigin​(String origin)

      Add a relative origin to the list of allowed Origins. A relative origin is a regex that should match the format `"://" [ ":" ]`.
      Parameters:
        `origin` - the well formatted static origin
      Returns:
        self

    - #### addOrigins

          public CorsHandler addOrigins​(List<String> origins)

      Set the list of allowed origins. An origin follows rfc6454#section-7 and is expected to have the format: `"://" [ ":" ]`
      Parameters:
        `origins` - the well formatted static origin list
      Returns:
        self

    - #### allowedMethod

          public CorsHandler allowedMethod​(HttpMethod method)

      Add an allowed method
      Parameters:
        `method` - the method to add
      Returns:
        a reference to this, so the API can be used fluently

    - #### allowedMethods

          public CorsHandler allowedMethods​(Set<HttpMethod> methods)

      Add a set of allowed methods
      Parameters:
        `methods` - the methods to add
      Returns:
        a reference to this, so the API can be used fluently

    - #### allowedHeader

          public CorsHandler allowedHeader​(String headerName)

      Add an allowed header
      Parameters:
        `headerName` - the allowed header name
      Returns:
        a reference to this, so the API can be used fluently

    - #### allowedHeaders

          public CorsHandler allowedHeaders​(Set<String> headerNames)

      Add a set of allowed headers
      Parameters:
        `headerNames` - the allowed header names
      Returns:
        a reference to this, so the API can be used fluently

    - #### exposedHeader

          public CorsHandler exposedHeader​(String headerName)

      Add an exposed header
      Parameters:
        `headerName` - the exposed header name
      Returns:
        a reference to this, so the API can be used fluently

    - #### exposedHeaders

          public CorsHandler exposedHeaders​(Set<String> headerNames)

      Add a set of exposed headers
      Parameters:
        `headerNames` - the exposed header names
      Returns:
        a reference to this, so the API can be used fluently

    - #### allowCredentials

          public CorsHandler allowCredentials​(boolean allow)

      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.

      Parameters:
        `allow` - true if allowed
      Returns:
        a reference to this, so the API can be used fluently

    - #### maxAgeSeconds

          public CorsHandler maxAgeSeconds​(int maxAgeSeconds)

      Set how long the browser should cache the information
      Parameters:
        `maxAgeSeconds` - max age in seconds
      Returns:
        a reference to this, so the API can be used fluently

    - #### allowPrivateNetwork

          public CorsHandler allowPrivateNetwork​(boolean allow)

      Set whether access from public to private networks are allowed. Defaults to false
      Parameters:
        `allow` - true if allowed
      Returns:
        a reference to this, so the API can be used fluently

    - #### newInstance

          public static CorsHandler newInstance​(CorsHandler arg)