Class: VertxWeb::Router
- Inherits:
-
Object
- Object
- VertxWeb::Router
- Defined in:
- /Users/julien/java/vertx-aggregator/modules/vertx-web/src/main/resources/vertx-web/router.rb
Overview
A router receives request from an Vertx::HttpServer and routes it to the first matching
Route that it contains. A router can contain many routes.
Routers are also used for routing failures.
Class Method Summary (collapse)
-
+ (::VertxWeb::Router) router(vertx = nil)
Create a router.
Instance Method Summary (collapse)
-
- (void) accept(request = nil)
This method is used to provide a request to the router.
-
- (self) clear
Remove all the routes from this router.
-
- (::VertxWeb::Route) connect(path = nil)
Add a route that matches a HTTP CONNECT request and the specified path.
-
- (::VertxWeb::Route) connect_with_regex(regex = nil)
Add a route that matches a HTTP CONNECT request and the specified path regex.
-
- (::VertxWeb::Route) delete(path = nil)
Add a route that matches a HTTP DELETE request and the specified path.
-
- (::VertxWeb::Route) delete_with_regex(regex = nil)
Add a route that matches a HTTP DELETE request and the specified path regex.
-
- (self) exception_handler { ... }
Specify a handler for any unhandled exceptions on this router.
-
- (::VertxWeb::Route) get(path = nil)
Add a route that matches a HTTP GET request and the specified path.
-
- (Array<::VertxWeb::Route>) get_routes
@return a list of all the routes on this router.
-
- (::VertxWeb::Route) get_with_regex(regex = nil)
Add a route that matches a HTTP GET request and the specified path regex.
-
- (void) handle_context(context = nil)
Used to route a context to the router.
-
- (void) handle_failure(context = nil)
Used to route a failure to the router.
-
- (::VertxWeb::Route) head(path = nil)
Add a route that matches a HTTP HEAD request and the specified path.
-
- (::VertxWeb::Route) head_with_regex(regex = nil)
Add a route that matches a HTTP HEAD request and the specified path regex.
-
- (self) mount_sub_router(mountPoint = nil, subRouter = nil)
Mount a sub router on this router.
-
- (::VertxWeb::Route) options(path = nil)
Add a route that matches a HTTP OPTIONS request and the specified path.
-
- (::VertxWeb::Route) options_with_regex(regex = nil)
Add a route that matches a HTTP OPTIONS request and the specified path regex.
-
- (::VertxWeb::Route) patch(path = nil)
Add a route that matches a HTTP PATCH request and the specified path.
-
- (::VertxWeb::Route) patch_with_regex(regex = nil)
Add a route that matches a HTTP PATCH request and the specified path regex.
-
- (::VertxWeb::Route) post(path = nil)
Add a route that matches a HTTP POST request and the specified path.
-
- (::VertxWeb::Route) post_with_regex(regex = nil)
Add a route that matches a HTTP POST request and the specified path regex.
-
- (::VertxWeb::Route) put(path = nil)
Add a route that matches a HTTP PUT request and the specified path.
-
- (::VertxWeb::Route) put_with_regex(regex = nil)
Add a route that matches a HTTP PUT request and the specified path regex.
-
- (::VertxWeb::Route) route(param_1 = nil, param_2 = nil)
Add a route that matches the specified HTTP method and path.
-
- (::VertxWeb::Route) route_with_regex(param_1 = nil, param_2 = nil)
Add a route that matches the specified HTTP method and path regex.
-
- (::VertxWeb::Route) trace(path = nil)
Add a route that matches a HTTP TRACE request and the specified path.
-
- (::VertxWeb::Route) trace_with_regex(regex = nil)
Add a route that matches a HTTP TRACE request and the specified path regex.
Class Method Details
+ (::VertxWeb::Router) router(vertx = nil)
Create a router
25 26 27 28 29 30 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-web/src/main/resources/vertx-web/router.rb', line 25 def self.router(vertx=nil) if vertx.class.method_defined?(:j_del) && !block_given? return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtWeb::Router.java_method(:router, [Java::IoVertxCore::Vertx.java_class]).call(vertx.j_del),::VertxWeb::Router) end raise ArgumentError, "Invalid arguments when calling router(vertx)" end |
Instance Method Details
- (void) accept(request = nil)
This method returns an undefined value.
This method is used to provide a request to the router. Usually you take request from the Vertx::HttpServer#request_handler and pass it to this method. The router then routes it to matching routes.
36 37 38 39 40 41 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-web/src/main/resources/vertx-web/router.rb', line 36 def accept(request=nil) if request.class.method_defined?(:j_del) && !block_given? return @j_del.java_method(:accept, [Java::IoVertxCoreHttp::HttpServerRequest.java_class]).call(request.j_del) end raise ArgumentError, "Invalid arguments when calling accept(request)" end |
- (self) clear
Remove all the routes from this router
265 266 267 268 269 270 271 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-web/src/main/resources/vertx-web/router.rb', line 265 def clear if !block_given? @j_del.java_method(:clear, []).call() return self end raise ArgumentError, "Invalid arguments when calling clear()" end |
- (::VertxWeb::Route) connect(path = nil)
Add a route that matches a HTTP CONNECT request and the specified path
218 219 220 221 222 223 224 225 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-web/src/main/resources/vertx-web/router.rb', line 218 def connect(path=nil) if !block_given? && path == nil return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:connect, []).call(),::VertxWeb::Route) elsif path.class == String && !block_given? return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:connect, [Java::java.lang.String.java_class]).call(path),::VertxWeb::Route) end raise ArgumentError, "Invalid arguments when calling connect(path)" end |
- (::VertxWeb::Route) connect_with_regex(regex = nil)
Add a route that matches a HTTP CONNECT request and the specified path regex
229 230 231 232 233 234 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-web/src/main/resources/vertx-web/router.rb', line 229 def connect_with_regex(regex=nil) if regex.class == String && !block_given? return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:connectWithRegex, [Java::java.lang.String.java_class]).call(regex),::VertxWeb::Route) end raise ArgumentError, "Invalid arguments when calling connect_with_regex(regex)" end |
- (::VertxWeb::Route) delete(path = nil)
Add a route that matches a HTTP DELETE request and the specified path
178 179 180 181 182 183 184 185 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-web/src/main/resources/vertx-web/router.rb', line 178 def delete(path=nil) if !block_given? && path == nil return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:delete, []).call(),::VertxWeb::Route) elsif path.class == String && !block_given? return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:delete, [Java::java.lang.String.java_class]).call(path),::VertxWeb::Route) end raise ArgumentError, "Invalid arguments when calling delete(path)" end |
- (::VertxWeb::Route) delete_with_regex(regex = nil)
Add a route that matches a HTTP DELETE request and the specified path regex
189 190 191 192 193 194 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-web/src/main/resources/vertx-web/router.rb', line 189 def delete_with_regex(regex=nil) if regex.class == String && !block_given? return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:deleteWithRegex, [Java::java.lang.String.java_class]).call(regex),::VertxWeb::Route) end raise ArgumentError, "Invalid arguments when calling delete_with_regex(regex)" end |
- (self) exception_handler { ... }
Specify a handler for any unhandled exceptions on this router. The handler will be called for exceptions thrown
from handlers. This does not affect the normal failure routing logic.
287 288 289 290 291 292 293 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-web/src/main/resources/vertx-web/router.rb', line 287 def exception_handler if block_given? @j_del.java_method(:exceptionHandler, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |event| yield(event) })) return self end raise ArgumentError, "Invalid arguments when calling exception_handler()" end |
- (::VertxWeb::Route) get(path = nil)
Add a route that matches a HTTP GET request and the specified path
78 79 80 81 82 83 84 85 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-web/src/main/resources/vertx-web/router.rb', line 78 def get(path=nil) if !block_given? && path == nil return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:get, []).call(),::VertxWeb::Route) elsif path.class == String && !block_given? return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:get, [Java::java.lang.String.java_class]).call(path),::VertxWeb::Route) end raise ArgumentError, "Invalid arguments when calling get(path)" end |
- (Array<::VertxWeb::Route>) get_routes
@return a list of all the routes on this router
257 258 259 260 261 262 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-web/src/main/resources/vertx-web/router.rb', line 257 def get_routes if !block_given? return @j_del.java_method(:getRoutes, []).call().to_a.map { |elt| ::Vertx::Util::Utils.safe_create(elt,::VertxWeb::Route) } end raise ArgumentError, "Invalid arguments when calling get_routes()" end |
- (::VertxWeb::Route) get_with_regex(regex = nil)
Add a route that matches a HTTP GET request and the specified path regex
89 90 91 92 93 94 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-web/src/main/resources/vertx-web/router.rb', line 89 def get_with_regex(regex=nil) if regex.class == String && !block_given? return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:getWithRegex, [Java::java.lang.String.java_class]).call(regex),::VertxWeb::Route) end raise ArgumentError, "Invalid arguments when calling get_with_regex(regex)" end |
- (void) handle_context(context = nil)
This method returns an undefined value.
Used to route a context to the router. Used for sub-routers. You wouldn't normally call this method directly.
297 298 299 300 301 302 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-web/src/main/resources/vertx-web/router.rb', line 297 def handle_context(context=nil) if context.class.method_defined?(:j_del) && !block_given? return @j_del.java_method(:handleContext, [Java::IoVertxExtWeb::RoutingContext.java_class]).call(context.j_del) end raise ArgumentError, "Invalid arguments when calling handle_context(context)" end |
- (void) handle_failure(context = nil)
This method returns an undefined value.
Used to route a failure to the router. Used for sub-routers. You wouldn't normally call this method directly.
306 307 308 309 310 311 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-web/src/main/resources/vertx-web/router.rb', line 306 def handle_failure(context=nil) if context.class.method_defined?(:j_del) && !block_given? return @j_del.java_method(:handleFailure, [Java::IoVertxExtWeb::RoutingContext.java_class]).call(context.j_del) end raise ArgumentError, "Invalid arguments when calling handle_failure(context)" end |
- (::VertxWeb::Route) head(path = nil)
Add a route that matches a HTTP HEAD request and the specified path
98 99 100 101 102 103 104 105 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-web/src/main/resources/vertx-web/router.rb', line 98 def head(path=nil) if !block_given? && path == nil return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:head, []).call(),::VertxWeb::Route) elsif path.class == String && !block_given? return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:head, [Java::java.lang.String.java_class]).call(path),::VertxWeb::Route) end raise ArgumentError, "Invalid arguments when calling head(path)" end |
- (::VertxWeb::Route) head_with_regex(regex = nil)
Add a route that matches a HTTP HEAD request and the specified path regex
109 110 111 112 113 114 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-web/src/main/resources/vertx-web/router.rb', line 109 def head_with_regex(regex=nil) if regex.class == String && !block_given? return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:headWithRegex, [Java::java.lang.String.java_class]).call(regex),::VertxWeb::Route) end raise ArgumentError, "Invalid arguments when calling head_with_regex(regex)" end |
- (self) mount_sub_router(mountPoint = nil, subRouter = nil)
Mount a sub router on this router
276 277 278 279 280 281 282 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-web/src/main/resources/vertx-web/router.rb', line 276 def mount_sub_router(mountPoint=nil,subRouter=nil) if mountPoint.class == String && subRouter.class.method_defined?(:j_del) && !block_given? @j_del.java_method(:mountSubRouter, [Java::java.lang.String.java_class,Java::IoVertxExtWeb::Router.java_class]).call(mountPoint,subRouter.j_del) return self end raise ArgumentError, "Invalid arguments when calling mount_sub_router(mountPoint,subRouter)" end |
- (::VertxWeb::Route) options(path = nil)
Add a route that matches a HTTP OPTIONS request and the specified path
118 119 120 121 122 123 124 125 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-web/src/main/resources/vertx-web/router.rb', line 118 def (path=nil) if !block_given? && path == nil return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:options, []).call(),::VertxWeb::Route) elsif path.class == String && !block_given? return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:options, [Java::java.lang.String.java_class]).call(path),::VertxWeb::Route) end raise ArgumentError, "Invalid arguments when calling options(path)" end |
- (::VertxWeb::Route) options_with_regex(regex = nil)
Add a route that matches a HTTP OPTIONS request and the specified path regex
129 130 131 132 133 134 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-web/src/main/resources/vertx-web/router.rb', line 129 def (regex=nil) if regex.class == String && !block_given? return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:optionsWithRegex, [Java::java.lang.String.java_class]).call(regex),::VertxWeb::Route) end raise ArgumentError, "Invalid arguments when calling options_with_regex(regex)" end |
- (::VertxWeb::Route) patch(path = nil)
Add a route that matches a HTTP PATCH request and the specified path
238 239 240 241 242 243 244 245 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-web/src/main/resources/vertx-web/router.rb', line 238 def patch(path=nil) if !block_given? && path == nil return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:patch, []).call(),::VertxWeb::Route) elsif path.class == String && !block_given? return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:patch, [Java::java.lang.String.java_class]).call(path),::VertxWeb::Route) end raise ArgumentError, "Invalid arguments when calling patch(path)" end |
- (::VertxWeb::Route) patch_with_regex(regex = nil)
Add a route that matches a HTTP PATCH request and the specified path regex
249 250 251 252 253 254 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-web/src/main/resources/vertx-web/router.rb', line 249 def patch_with_regex(regex=nil) if regex.class == String && !block_given? return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:patchWithRegex, [Java::java.lang.String.java_class]).call(regex),::VertxWeb::Route) end raise ArgumentError, "Invalid arguments when calling patch_with_regex(regex)" end |
- (::VertxWeb::Route) post(path = nil)
Add a route that matches a HTTP POST request and the specified path
158 159 160 161 162 163 164 165 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-web/src/main/resources/vertx-web/router.rb', line 158 def post(path=nil) if !block_given? && path == nil return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:post, []).call(),::VertxWeb::Route) elsif path.class == String && !block_given? return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:post, [Java::java.lang.String.java_class]).call(path),::VertxWeb::Route) end raise ArgumentError, "Invalid arguments when calling post(path)" end |
- (::VertxWeb::Route) post_with_regex(regex = nil)
Add a route that matches a HTTP POST request and the specified path regex
169 170 171 172 173 174 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-web/src/main/resources/vertx-web/router.rb', line 169 def post_with_regex(regex=nil) if regex.class == String && !block_given? return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:postWithRegex, [Java::java.lang.String.java_class]).call(regex),::VertxWeb::Route) end raise ArgumentError, "Invalid arguments when calling post_with_regex(regex)" end |
- (::VertxWeb::Route) put(path = nil)
Add a route that matches a HTTP PUT request and the specified path
138 139 140 141 142 143 144 145 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-web/src/main/resources/vertx-web/router.rb', line 138 def put(path=nil) if !block_given? && path == nil return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:put, []).call(),::VertxWeb::Route) elsif path.class == String && !block_given? return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:put, [Java::java.lang.String.java_class]).call(path),::VertxWeb::Route) end raise ArgumentError, "Invalid arguments when calling put(path)" end |
- (::VertxWeb::Route) put_with_regex(regex = nil)
Add a route that matches a HTTP PUT request and the specified path regex
149 150 151 152 153 154 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-web/src/main/resources/vertx-web/router.rb', line 149 def put_with_regex(regex=nil) if regex.class == String && !block_given? return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:putWithRegex, [Java::java.lang.String.java_class]).call(regex),::VertxWeb::Route) end raise ArgumentError, "Invalid arguments when calling put_with_regex(regex)" end |
- (::VertxWeb::Route) route - (::VertxWeb::Route) route(path) - (::VertxWeb::Route) route(method, path)
Add a route that matches the specified HTTP method and path
50 51 52 53 54 55 56 57 58 59 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-web/src/main/resources/vertx-web/router.rb', line 50 def route(param_1=nil,param_2=nil) if !block_given? && param_1 == nil && param_2 == nil return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:route, []).call(),::VertxWeb::Route) elsif param_1.class == String && !block_given? && param_2 == nil return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:route, [Java::java.lang.String.java_class]).call(param_1),::VertxWeb::Route) elsif param_1.class == Symbol && param_2.class == String && !block_given? return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:route, [Java::IoVertxCoreHttp::HttpMethod.java_class,Java::java.lang.String.java_class]).call(Java::IoVertxCoreHttp::HttpMethod.valueOf(param_1),param_2),::VertxWeb::Route) end raise ArgumentError, "Invalid arguments when calling route(param_1,param_2)" end |
- (::VertxWeb::Route) routeWithRegex(regex) - (::VertxWeb::Route) routeWithRegex(method, regex)
Add a route that matches the specified HTTP method and path regex
67 68 69 70 71 72 73 74 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-web/src/main/resources/vertx-web/router.rb', line 67 def route_with_regex(param_1=nil,param_2=nil) if param_1.class == String && !block_given? && param_2 == nil return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:routeWithRegex, [Java::java.lang.String.java_class]).call(param_1),::VertxWeb::Route) elsif param_1.class == Symbol && param_2.class == String && !block_given? return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:routeWithRegex, [Java::IoVertxCoreHttp::HttpMethod.java_class,Java::java.lang.String.java_class]).call(Java::IoVertxCoreHttp::HttpMethod.valueOf(param_1),param_2),::VertxWeb::Route) end raise ArgumentError, "Invalid arguments when calling route_with_regex(param_1,param_2)" end |
- (::VertxWeb::Route) trace(path = nil)
Add a route that matches a HTTP TRACE request and the specified path
198 199 200 201 202 203 204 205 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-web/src/main/resources/vertx-web/router.rb', line 198 def trace(path=nil) if !block_given? && path == nil return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:trace, []).call(),::VertxWeb::Route) elsif path.class == String && !block_given? return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:trace, [Java::java.lang.String.java_class]).call(path),::VertxWeb::Route) end raise ArgumentError, "Invalid arguments when calling trace(path)" end |
- (::VertxWeb::Route) trace_with_regex(regex = nil)
Add a route that matches a HTTP TRACE request and the specified path regex
209 210 211 212 213 214 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-web/src/main/resources/vertx-web/router.rb', line 209 def trace_with_regex(regex=nil) if regex.class == String && !block_given? return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:traceWithRegex, [Java::java.lang.String.java_class]).call(regex),::VertxWeb::Route) end raise ArgumentError, "Invalid arguments when calling trace_with_regex(regex)" end |