Class: VertxWeb::ResponseContentTypeHandler

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

Overview

A handler which sets the response content type automatically according to the best Accept header match. The header is set only if:
  • no object is stored in the routing context under the name DEFAULT_DISABLE_FLAG
  • a match is found
  • the header is not present already
  • content length header is absent or set to something different than zero

Constant Summary

@@j_api_type =
Object.new

Class Method Summary (collapse)

Instance Method Summary (collapse)

Class Method Details

+ (Boolean) accept?(obj)

Returns:

  • (Boolean)


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

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

+ (::VertxWeb::ResponseContentTypeHandler) create(disableFlag = nil)

Create a response content type handler with a custom disable flag.

Parameters:

  • disableFlag (String) (defaults to: nil)

Returns:

Raises:

  • (ArgumentError)


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

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

+ (Object) DEFAULT_DISABLE_FLAG



61
62
63
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/response_content_type_handler.rb', line 61

def self.DEFAULT_DISABLE_FLAG
  Java::IoVertxExtWebHandler::ResponseContentTypeHandler.DEFAULT_DISABLE_FLAG
end

+ (Object) j_api_type



35
36
37
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/response_content_type_handler.rb', line 35

def self.j_api_type
  @@j_api_type
end

+ (Object) j_class



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

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

+ (Object) unwrap(obj)



32
33
34
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/response_content_type_handler.rb', line 32

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

+ (Object) wrap(obj)



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

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

Instance Method Details

- (void) handle(event = nil)

This method returns an undefined value.

Something has happened, so handle it.

Parameters:

Raises:

  • (ArgumentError)


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

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