Class: VertxWeb::CorsHandler

Inherits:
Object
  • Object
show all
Defined in:
/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/cors_handler.rb

Overview

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

Constant Summary

@@j_api_type =
Object.new

Class Method Summary (collapse)

Instance Method Summary (collapse)

Class Method Details

+ (Boolean) accept?(obj)

Returns:

  • (Boolean)


18
19
20
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/cors_handler.rb', line 18

def @@j_api_type.accept?(obj)
  obj.class == CorsHandler
end

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

Create a CORS handler

Parameters:

  • allowedOriginPattern (String) (defaults to: nil)
    the allowed origin pattern

Returns:

Raises:

  • (ArgumentError)


45
46
47
48
49
50
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/cors_handler.rb', line 45

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

+ (Object) j_api_type



27
28
29
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/cors_handler.rb', line 27

def self.j_api_type
  @@j_api_type
end

+ (Object) j_class



30
31
32
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/cors_handler.rb', line 30

def self.j_class
  Java::IoVertxExtWebHandler::CorsHandler.java_class
end

+ (Object) unwrap(obj)



24
25
26
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/cors_handler.rb', line 24

def @@j_api_type.unwrap(obj)
  obj.j_del
end

+ (Object) wrap(obj)



21
22
23
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/cors_handler.rb', line 21

def @@j_api_type.wrap(obj)
  CorsHandler.new(obj)
end

Instance Method Details

- (self) allow_credentials(allow = nil)

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, false) (defaults to: nil)
    true if allowed

Returns:

  • (self)

Raises:

  • (ArgumentError)


112
113
114
115
116
117
118
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/cors_handler.rb', line 112

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)


64
65
66
67
68
69
70
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/cors_handler.rb', line 64

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)


74
75
76
77
78
79
80
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/cors_handler.rb', line 74

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, :OTHER) (defaults to: nil)
    the method to add

Returns:

  • (self)

Raises:

  • (ArgumentError)


54
55
56
57
58
59
60
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/cors_handler.rb', line 54

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.to_s))
    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)


84
85
86
87
88
89
90
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/cors_handler.rb', line 84

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)


94
95
96
97
98
99
100
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/cors_handler.rb', line 94

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(event = nil)

This method returns an undefined value.

Something has happened, so handle it.

Parameters:

Raises:

  • (ArgumentError)


36
37
38
39
40
41
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/cors_handler.rb', line 36

def handle(event=nil)
  if event.class.method_defined?(:j_del) && !block_given?
    return @j_del.java_method(:handle, [Java::IoVertxExtWeb::RoutingContext.java_class]).call(event.j_del)
  end
  raise ArgumentError, "Invalid arguments when calling handle(#{event})"
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)


122
123
124
125
126
127
128
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/cors_handler.rb', line 122

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