Class: VertxApex::Route
- Inherits:
-
Object
- Object
- VertxApex::Route
- Defined in:
- /Users/julien/java/vertx-aggregator/modules/vertx-apex/src/main/resources/vertx-apex/route.rb
Overview
A route is a holder for a set of criteria which determine whether an HTTP request or failure should be routed
to a handler.
Instance Method Summary (collapse)
-
- (self) blocking_handler { ... }
Specify a blocking request handler for the route.
-
- (self) consumes(contentType = nil)
Add a content type consumed by this route.
-
- (self) disable
Disable this route.
-
- (self) enable
Enable this route.
-
- (self) failure_handler { ... }
Specify a failure handler for the route.
-
- (String) get_path
@return the path prefix (if any) for this route.
-
- (self) handler { ... }
Specify a request handler for the route.
-
- (self) last(last = nil)
Specify whether this is the last route for the router.
-
- (self) method(method = nil)
Add an HTTP method for this route.
-
- (self) order(order = nil)
Specify the order for this route.
-
- (self) path(path = nil)
Set the path prefix for this route.
-
- (self) path_regex(path = nil)
Set the path prefix as a regular expression.
-
- (::VertxApex::Route) produces(contentType = nil)
Add a content type produced by this route.
-
- (self) remove
Remove this route from the router.
-
- (self) use_normalised_path(useNormalisedPath = nil)
If true then the normalised request path will be used when routing (e.g. removing duplicate /) Default is true.
Instance Method Details
- (self) blocking_handler { ... }
Specify a blocking request handler for the route.
This method works just like #handler excepted that it will run the blocking handler on a different thread
so that it won't block the event loop. Note that it's safe to call context.next() from the
blocking handler as it will be executed on the event loop context (and not on the worker thread)
108 109 110 111 112 113 114 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-apex/src/main/resources/vertx-apex/route.rb', line 108 def blocking_handler if block_given? @j_del.java_method(:blockingHandler, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |event| yield(::VertxApex::RoutingContext.new(event)) })) return self end raise ArgumentError, "Invalid arguments when calling blocking_handler()" end |
- (self) consumes(contentType = nil)
Add a content type consumed by this route. Used for content based routing.
63 64 65 66 67 68 69 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-apex/src/main/resources/vertx-apex/route.rb', line 63 def consumes(contentType=nil) if contentType.class == String && !block_given? @j_del.java_method(:consumes, [Java::java.lang.String.java_class]).call(contentType) return self end raise ArgumentError, "Invalid arguments when calling consumes(contentType)" end |
- (self) disable
Disable this route. While disabled the router will not route any requests or failures to it.
138 139 140 141 142 143 144 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-apex/src/main/resources/vertx-apex/route.rb', line 138 def disable if !block_given? @j_del.java_method(:disable, []).call() return self end raise ArgumentError, "Invalid arguments when calling disable()" end |
- (self) enable
Enable this route.
147 148 149 150 151 152 153 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-apex/src/main/resources/vertx-apex/route.rb', line 147 def enable if !block_given? @j_del.java_method(:enable, []).call() return self end raise ArgumentError, "Invalid arguments when calling enable()" end |
- (self) failure_handler { ... }
Specify a failure handler for the route. The router routes failures to failurehandlers depending on whether the various
criteria such as method, path, etc match. There can be only one failure handler for a route. If you set this more
than once it will overwrite the previous handler.
120 121 122 123 124 125 126 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-apex/src/main/resources/vertx-apex/route.rb', line 120 def failure_handler if block_given? @j_del.java_method(:failureHandler, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |event| yield(::VertxApex::RoutingContext.new(event)) })) return self end raise ArgumentError, "Invalid arguments when calling failure_handler()" end |
- (String) get_path
@return the path prefix (if any) for this route
167 168 169 170 171 172 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-apex/src/main/resources/vertx-apex/route.rb', line 167 def get_path if !block_given? return @j_del.java_method(:getPath, []).call() end raise ArgumentError, "Invalid arguments when calling get_path()" end |
- (self) handler { ... }
Specify a request handler for the route. The router routes requests to handlers depending on whether the various
criteria such as method, path, etc match. There can be only one request handler for a route. If you set this more
than once it will overwrite the previous handler.
95 96 97 98 99 100 101 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-apex/src/main/resources/vertx-apex/route.rb', line 95 def handler if block_given? @j_del.java_method(:handler, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |event| yield(::VertxApex::RoutingContext.new(event)) })) return self end raise ArgumentError, "Invalid arguments when calling handler()" end |
- (self) last(last = nil)
Specify whether this is the last route for the router.
83 84 85 86 87 88 89 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-apex/src/main/resources/vertx-apex/route.rb', line 83 def last(last=nil) if (last.class == TrueClass || last.class == FalseClass) && !block_given? @j_del.java_method(:last, [Java::boolean.java_class]).call(last) return self end raise ArgumentError, "Invalid arguments when calling last(last)" end |
- (self) method(method = nil)
Add an HTTP method for this route. By default a route will match all HTTP methods. If any are specified then the route
will only match any of the specified methods
22 23 24 25 26 27 28 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-apex/src/main/resources/vertx-apex/route.rb', line 22 def method(method=nil) if method.class == Symbol && !block_given? @j_del.java_method(:method, [Java::IoVertxCoreHttp::HttpMethod.java_class]).call(Java::IoVertxCoreHttp::HttpMethod.valueOf(method)) return self end raise ArgumentError, "Invalid arguments when calling method(method)" end |
- (self) order(order = nil)
Specify the order for this route. The router tests routes in that order.
73 74 75 76 77 78 79 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-apex/src/main/resources/vertx-apex/route.rb', line 73 def order(order=nil) if order.class == Fixnum && !block_given? @j_del.java_method(:order, [Java::int.java_class]).call(order) return self end raise ArgumentError, "Invalid arguments when calling order(order)" end |
- (self) path(path = nil)
Set the path prefix for this route. If set then this route will only match request URI paths which start with this
path prefix. Only a single path or path regex can be set for a route.
33 34 35 36 37 38 39 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-apex/src/main/resources/vertx-apex/route.rb', line 33 def path(path=nil) if path.class == String && !block_given? @j_del.java_method(:path, [Java::java.lang.String.java_class]).call(path) return self end raise ArgumentError, "Invalid arguments when calling path(path)" end |
- (self) path_regex(path = nil)
Set the path prefix as a regular expression. If set then this route will only match request URI paths, the beginning
of which match the regex. Only a single path or path regex can be set for a route.
44 45 46 47 48 49 50 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-apex/src/main/resources/vertx-apex/route.rb', line 44 def path_regex(path=nil) if path.class == String && !block_given? @j_del.java_method(:pathRegex, [Java::java.lang.String.java_class]).call(path) return self end raise ArgumentError, "Invalid arguments when calling path_regex(path)" end |
- (::VertxApex::Route) produces(contentType = nil)
Add a content type produced by this route. Used for content based routing.
54 55 56 57 58 59 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-apex/src/main/resources/vertx-apex/route.rb', line 54 def produces(contentType=nil) if contentType.class == String && !block_given? return ::VertxApex::Route.new(@j_del.java_method(:produces, [Java::java.lang.String.java_class]).call(contentType)) end raise ArgumentError, "Invalid arguments when calling produces(contentType)" end |
- (self) remove
Remove this route from the router
129 130 131 132 133 134 135 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-apex/src/main/resources/vertx-apex/route.rb', line 129 def remove if !block_given? @j_del.java_method(:remove, []).call() return self end raise ArgumentError, "Invalid arguments when calling remove()" end |
- (self) use_normalised_path(useNormalisedPath = nil)
If true then the normalised request path will be used when routing (e.g. removing duplicate /)
Default is true
158 159 160 161 162 163 164 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-apex/src/main/resources/vertx-apex/route.rb', line 158 def use_normalised_path(useNormalisedPath=nil) if (useNormalisedPath.class == TrueClass || useNormalisedPath.class == FalseClass) && !block_given? @j_del.java_method(:useNormalisedPath, [Java::boolean.java_class]).call(useNormalisedPath) return self end raise ArgumentError, "Invalid arguments when calling use_normalised_path(useNormalisedPath)" end |