Class: VertxWeb::Router
- Inherits:
-
Object
- Object
- VertxWeb::Router
- Defined in:
- /Users/julien/java/vertx-stack/stack-docs/target/rb/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.
Constant Summary
- @@j_api_type =
Object.new
Class Method Summary (collapse)
- + (Boolean) accept?(obj)
- + (Object) j_api_type
- + (Object) j_class
-
+ (::VertxWeb::Router) router(vertx = nil)
Create a router.
- + (Object) unwrap(obj)
- + (Object) wrap(obj)
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
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
+ (Boolean) accept?(obj)
24 25 26 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web/router.rb', line 24 def @@j_api_type.accept?(obj) obj.class == Router end |
+ (Object) j_api_type
33 34 35 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web/router.rb', line 33 def self.j_api_type @@j_api_type end |
+ (Object) j_class
36 37 38 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web/router.rb', line 36 def self.j_class Java::IoVertxExtWeb::Router.java_class end |
+ (::VertxWeb::Router) router(vertx = nil)
Create a router
42 43 44 45 46 47 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web/router.rb', line 42 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 |
+ (Object) unwrap(obj)
30 31 32 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web/router.rb', line 30 def @@j_api_type.unwrap(obj) obj.j_del end |
+ (Object) wrap(obj)
27 28 29 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web/router.rb', line 27 def @@j_api_type.wrap(obj) Router.new(obj) 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.
53 54 55 56 57 58 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web/router.rb', line 53 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
281 282 283 284 285 286 287 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web/router.rb', line 281 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
235 236 237 238 239 240 241 242 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web/router.rb', line 235 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
246 247 248 249 250 251 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web/router.rb', line 246 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
195 196 197 198 199 200 201 202 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web/router.rb', line 195 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
206 207 208 209 210 211 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web/router.rb', line 206 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.
303 304 305 306 307 308 309 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web/router.rb', line 303 def exception_handler if block_given? @j_del.java_method(:exceptionHandler, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |event| yield(::Vertx::Util::Utils.from_throwable(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
95 96 97 98 99 100 101 102 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web/router.rb', line 95 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
Returns a list of all the routes on this router
273 274 275 276 277 278 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web/router.rb', line 273 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
106 107 108 109 110 111 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web/router.rb', line 106 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.
313 314 315 316 317 318 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web/router.rb', line 313 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.
322 323 324 325 326 327 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web/router.rb', line 322 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
115 116 117 118 119 120 121 122 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web/router.rb', line 115 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
126 127 128 129 130 131 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web/router.rb', line 126 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
292 293 294 295 296 297 298 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web/router.rb', line 292 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
135 136 137 138 139 140 141 142 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web/router.rb', line 135 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
146 147 148 149 150 151 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web/router.rb', line 146 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
255 256 257 258 259 260 261 262 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web/router.rb', line 255 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
266 267 268 269 270 271 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web/router.rb', line 266 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
175 176 177 178 179 180 181 182 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web/router.rb', line 175 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
186 187 188 189 190 191 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web/router.rb', line 186 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
155 156 157 158 159 160 161 162 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web/router.rb', line 155 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
166 167 168 169 170 171 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web/router.rb', line 166 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
67 68 69 70 71 72 73 74 75 76 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web/router.rb', line 67 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.to_s),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
84 85 86 87 88 89 90 91 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web/router.rb', line 84 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.to_s),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
215 216 217 218 219 220 221 222 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web/router.rb', line 215 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
226 227 228 229 230 231 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web/router.rb', line 226 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 |