Module: VertxWebApiContract::DesignDrivenRouterFactory

Included in:
DesignDrivenRouterFactoryImpl
Defined in:
/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web-api-contract/design_driven_router_factory.rb

Instance Method Summary (collapse)

Instance Method Details

- (self) add_failure_handler(method = nil, path = nil) { ... }

Add a failure handler to a path with a method. If combination path/method is not available in specification, it will throw a Nil

Parameters:

  • method (:OPTIONS, :GET, :HEAD, :POST, :PUT, :DELETE, :TRACE, :CONNECT, :PATCH, :OTHER) (defaults to: nil)
  • path (String) (defaults to: nil)

Yields:

Returns:

  • (self)

Raises:

  • (ArgumentError)


37
38
39
40
41
42
43
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web-api-contract/design_driven_router_factory.rb', line 37

def add_failure_handler(method=nil,path=nil)
  if method.class == Symbol && path.class == String && block_given?
    @j_del.java_method(:addFailureHandler, [Java::IoVertxCoreHttp::HttpMethod.java_class,Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class]).call(Java::IoVertxCoreHttp::HttpMethod.valueOf(method.to_s),path,(Proc.new { |event| yield(::Vertx::Util::Utils.safe_create(event,::VertxWeb::RoutingContext)) }))
    return self
  end
  raise ArgumentError, "Invalid arguments when calling add_failure_handler(#{method},#{path})"
end

- (self) add_handler(method = nil, path = nil) { ... }

Add an handler to a path with a method. If combination path/method is not available in specification, it will throw a Nil

Parameters:

  • method (:OPTIONS, :GET, :HEAD, :POST, :PUT, :DELETE, :TRACE, :CONNECT, :PATCH, :OTHER) (defaults to: nil)
  • path (String) (defaults to: nil)

Yields:

Returns:

  • (self)

Raises:

  • (ArgumentError)


24
25
26
27
28
29
30
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web-api-contract/design_driven_router_factory.rb', line 24

def add_handler(method=nil,path=nil)
  if method.class == Symbol && path.class == String && block_given?
    @j_del.java_method(:addHandler, [Java::IoVertxCoreHttp::HttpMethod.java_class,Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class]).call(Java::IoVertxCoreHttp::HttpMethod.valueOf(method.to_s),path,(Proc.new { |event| yield(::Vertx::Util::Utils.safe_create(event,::VertxWeb::RoutingContext)) }))
    return self
  end
  raise ArgumentError, "Invalid arguments when calling add_handler(#{method},#{path})"
end

- (self) add_security_handler(securitySchemaName = nil) { ... }

Mount to paths that have to follow a security schema a security handler

Parameters:

  • securitySchemaName (String) (defaults to: nil)

Yields:

Returns:

  • (self)

Raises:

  • (ArgumentError)


11
12
13
14
15
16
17
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web-api-contract/design_driven_router_factory.rb', line 11

def add_security_handler(securitySchemaName=nil)
  if securitySchemaName.class == String && block_given?
    @j_del.java_method(:addSecurityHandler, [Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class]).call(securitySchemaName,(Proc.new { |event| yield(::Vertx::Util::Utils.safe_create(event,::VertxWeb::RoutingContext)) }))
    return self
  end
  raise ArgumentError, "Invalid arguments when calling add_security_handler(#{securitySchemaName})"
end

- (self) enable_validation_failure_handler(enable = nil)

Enable or disable validation failure handler. If you enable it, during router creation it will be mounted a built-in (or custom with function #set_validation_failure_handler) ValidationException handler as a failure handler. If failure is different from ValidationException, it will be called the next failure handler.

Parameters:

  • enable (true, false) (defaults to: nil)

Returns:

  • (self)

Raises:

  • (ArgumentError)


61
62
63
64
65
66
67
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web-api-contract/design_driven_router_factory.rb', line 61

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

- (::VertxWeb::Router) get_router

Construct a new router based on spec. It will fail if you are trying to mount a spec with security schemes without assigned handlers
Note: Router is constructed in this function, so it will be respected the path definition ordering.

Returns:

Raises:

  • (ArgumentError)


82
83
84
85
86
87
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web-api-contract/design_driven_router_factory.rb', line 82

def get_router
  if !block_given?
    return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:getRouter, []).call(),::VertxWeb::Router)
  end
  raise ArgumentError, "Invalid arguments when calling get_router()"
end

- (self) mount_operations_without_handlers(enable = nil)

Automatic mount handlers that return HTTP 501 status code for operations where you didn't specify an handler.

Parameters:

  • enable (true, false) (defaults to: nil)

Returns:

  • (self)

Raises:

  • (ArgumentError)


71
72
73
74
75
76
77
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web-api-contract/design_driven_router_factory.rb', line 71

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

- (self) set_validation_failure_handler { ... }

Set default validation failure handler. You can disable this feature from #enable_validation_failure_handler

Yields:

Returns:

  • (self)

Raises:

  • (ArgumentError)


48
49
50
51
52
53
54
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web-api-contract/design_driven_router_factory.rb', line 48

def set_validation_failure_handler
  if block_given?
    @j_del.java_method(:setValidationFailureHandler, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |event| yield(::Vertx::Util::Utils.safe_create(event,::VertxWeb::RoutingContext)) }))
    return self
  end
  raise ArgumentError, "Invalid arguments when calling set_validation_failure_handler()"
end