Class List Method List File List

# Class: VertxWeb::CorsHandler

Inherits:
  Object
  - Object
  - VertxWeb::CorsHandler
  show all
Defined in:
  /Users/julien/java/vertx-aggregator/modules/vertx-web/vertx-web/src/main/resources/vertx-web/cors_handler.rb

## Overview

A handler which implements server side http://www.w3.org/TR/cors/[CORS] support for Vert.x-Web.

## Class Method Summary (collapse)

- + (::VertxWeb::CorsHandler) create(allowedOriginPattern = nil)
  Create a CORS handler.

## Instance Method Summary (collapse)

- - (self) allow_credentials(allow = nil)
  Set whether credentials are allowed.
- - (self) allowed_header(headerName = nil)
  Add an allowed header.
- - (self) allowed_headers(headerNames = nil)
  Add a set of allowed headers.
- - (self) allowed_method(method = nil)
  Add an allowed method.
- - (self) exposed_header(headerName = nil)
  Add an exposed header.
- - (self) exposed_headers(headerNames = nil)
  Add a set of exposed headers.
- - (void) handle(arg0 = nil)
- - (self) max_age_seconds(maxAgeSeconds = nil)
  Set how long the browser should cache the information.

## Class Method Details

### + (`::VertxWeb::CorsHandler`) create(allowedOriginPattern = nil)

Create a CORS handler

Parameters:

- allowedOriginPattern (`String`) (defaults to: `nil`) —
  the allowed origin pattern

Returns:

- (`::VertxWeb::CorsHandler`) —
  the handler

Raises:

- (`ArgumentError`)

    28
    29
    30
    31
    32
    33
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-web/vertx-web/src/main/resources/vertx-web/cors_handler.rb', line 28

    def self.create(allowedOriginPattern=nil)
      if allowedOriginPattern.class == String && !block_given?
        return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtWebHandler::CorsHandler.java_method(:create, [Java::java.lang.String.java_class]).call(allowedOriginPattern),::VertxWeb::CorsHandler)
      end
      raise ArgumentError, "Invalid arguments when calling create(allowedOriginPattern)"
    end

## Instance Method Details

### - (`self`) allow_credentials(allow = nil)

Set whether credentials are allowed

Parameters:

- allow (`true`, `false`) (defaults to: `nil`) —
  true if allowed

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    87
    88
    89
    90
    91
    92
    93
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-web/vertx-web/src/main/resources/vertx-web/cors_handler.rb', line 87

    def allow_credentials(allow=nil)
      if (allow.class == TrueClass || allow.class == FalseClass) && !block_given?
        @j_del.java_method(:allowCredentials, [Java::boolean.java_class]).call(allow)
        return self
      end
      raise ArgumentError, "Invalid arguments when calling allow_credentials(allow)"
    end

### - (`self`) allowed_header(headerName = nil)

Add an allowed header

Parameters:

- headerName (`String`) (defaults to: `nil`) —
  the allowed header name

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    47
    48
    49
    50
    51
    52
    53
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-web/vertx-web/src/main/resources/vertx-web/cors_handler.rb', line 47

    def allowed_header(headerName=nil)
      if headerName.class == String && !block_given?
        @j_del.java_method(:allowedHeader, [Java::java.lang.String.java_class]).call(headerName)
        return self
      end
      raise ArgumentError, "Invalid arguments when calling allowed_header(headerName)"
    end

### - (`self`) allowed_headers(headerNames = nil)

Add a set of allowed headers

Parameters:

- headerNames (`Set<String>`) (defaults to: `nil`) —
  the allowed header names

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    57
    58
    59
    60
    61
    62
    63
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-web/vertx-web/src/main/resources/vertx-web/cors_handler.rb', line 57

    def allowed_headers(headerNames=nil)
      if headerNames.class == Set && !block_given?
        @j_del.java_method(:allowedHeaders, [Java::JavaUtil::Set.java_class]).call(Java::JavaUtil::LinkedHashSet.new(headerNames.map { |element| element }))
        return self
      end
      raise ArgumentError, "Invalid arguments when calling allowed_headers(headerNames)"
    end

### - (`self`) allowed_method(method = nil)

Add an allowed method

Parameters:

- method (`:OPTIONS`, `:GET`, `:HEAD`, `:POST`, `:PUT`, `:DELETE`, `:TRACE`, `:CONNECT`, `:PATCH`) (defaults to: `nil`) —
  the method to add

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    37
    38
    39
    40
    41
    42
    43
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-web/vertx-web/src/main/resources/vertx-web/cors_handler.rb', line 37

    def allowed_method(method=nil)
      if method.class == Symbol && !block_given?
        @j_del.java_method(:allowedMethod, [Java::IoVertxCoreHttp::HttpMethod.java_class]).call(Java::IoVertxCoreHttp::HttpMethod.valueOf(method))
        return self
      end
      raise ArgumentError, "Invalid arguments when calling allowed_method(method)"
    end

### - (`self`) exposed_header(headerName = nil)

Add an exposed header

Parameters:

- headerName (`String`) (defaults to: `nil`) —
  the exposed header name

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    67
    68
    69
    70
    71
    72
    73
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-web/vertx-web/src/main/resources/vertx-web/cors_handler.rb', line 67

    def exposed_header(headerName=nil)
      if headerName.class == String && !block_given?
        @j_del.java_method(:exposedHeader, [Java::java.lang.String.java_class]).call(headerName)
        return self
      end
      raise ArgumentError, "Invalid arguments when calling exposed_header(headerName)"
    end

### - (`self`) exposed_headers(headerNames = nil)

Add a set of exposed headers

Parameters:

- headerNames (`Set<String>`) (defaults to: `nil`) —
  the exposed header names

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    77
    78
    79
    80
    81
    82
    83
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-web/vertx-web/src/main/resources/vertx-web/cors_handler.rb', line 77

    def exposed_headers(headerNames=nil)
      if headerNames.class == Set && !block_given?
        @j_del.java_method(:exposedHeaders, [Java::JavaUtil::Set.java_class]).call(Java::JavaUtil::LinkedHashSet.new(headerNames.map { |element| element }))
        return self
      end
      raise ArgumentError, "Invalid arguments when calling exposed_headers(headerNames)"
    end

### - (`void`) handle(arg0 = nil)

This method returns an undefined value.

Parameters:

- arg0 (`::VertxWeb::RoutingContext`) (defaults to: `nil`)

Raises:

- (`ArgumentError`)

    19
    20
    21
    22
    23
    24
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-web/vertx-web/src/main/resources/vertx-web/cors_handler.rb', line 19

    def handle(arg0=nil)
      if arg0.class.method_defined?(:j_del) && !block_given?
        return @j_del.java_method(:handle, [Java::IoVertxExtWeb::RoutingContext.java_class]).call(arg0.j_del)
      end
      raise ArgumentError, "Invalid arguments when calling handle(arg0)"
    end

### - (`self`) max_age_seconds(maxAgeSeconds = nil)

Set how long the browser should cache the information

Parameters:

- maxAgeSeconds (`Fixnum`) (defaults to: `nil`) —
  max age in seconds

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    97
    98
    99
    100
    101
    102
    103
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-web/vertx-web/src/main/resources/vertx-web/cors_handler.rb', line 97

    def max_age_seconds(maxAgeSeconds=nil)
      if maxAgeSeconds.class == Fixnum && !block_given?
        @j_del.java_method(:maxAgeSeconds, [Java::int.java_class]).call(maxAgeSeconds)
        return self
      end
      raise ArgumentError, "Invalid arguments when calling max_age_seconds(maxAgeSeconds)"
    end