Class: VertxWeb::RoutingContext

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

Overview

Represents the context for the handling of a request in Vert.x-Web.

A new instance is created for each HTTP request that is received in the Proc#handle of the router.

The same instance is passed to any matching request or failure handlers during the routing of the request or failure.

The context provides access to the and and allows you to maintain arbitrary data that lives for the lifetime of the context. Contexts are discarded once they have been routed to the handler for the request.

The context also provides access to the Session, cookies and body for the request, given the correct handlers in the application.

If you use the internal error handler

Constant Summary

@@j_api_type =
Object.new

Class Method Summary (collapse)

Instance Method Summary (collapse)

Class Method Details

+ (Boolean) accept?(obj)

Returns:

  • (Boolean)


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

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

+ (Object) j_api_type



55
56
57
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/routing_context.rb', line 55

def self.j_api_type
  @@j_api_type
end

+ (Object) j_class



58
59
60
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/routing_context.rb', line 58

def self.j_class
  Java::IoVertxExtWeb::RoutingContext.java_class
end

+ (Object) unwrap(obj)



52
53
54
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/routing_context.rb', line 52

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

+ (Object) wrap(obj)



49
50
51
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/routing_context.rb', line 49

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

Instance Method Details

- (Array<::VertxWeb::LanguageHeader>) acceptableLanguages

Returns the languages for the current request. The languages are determined from the Accept-Language header and sorted on quality. When 2 or more entries have the same quality then the order used to return the best match is based on the lowest index on the original list. For example if a user has en-US and en-GB with same quality and this order the best match will be en-US because it was declared as first entry by the client.

Returns:



189
190
191
192
193
194
195
196
197
198
199
200
201
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/routing_context.rb', line 189

def acceptable_languages
  if !block_given?
    if @cached_acceptable_languages != nil
      return @cached_acceptable_languages
    end
    return @cached_acceptable_languages = @j_del.java_method(:acceptableLanguages, []).call().to_a.map { |elt| ::Vertx::Util::Utils.safe_create(elt,::VertxWeb::LanguageHeader) }
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling acceptable_languages()"
  end
end

- (Fixnum) addBodyEndHandler(handler) { ... }

Provides a handler that will be called after the last part of the body is written to the wire. The handler is called asynchronously of when the response has been received by the client. This provides a hook allowing you to do more operations once the request has been sent over the wire. Do not use this for resource cleanup as this handler might never get called (e.g. if the connection is reset).

Yields:

  • the handler

Returns:

  • (Fixnum)
    the id of the handler. This can be used if you later want to remove the handler.


100
101
102
103
104
105
106
107
108
109
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/routing_context.rb', line 100

def add_body_end_handler
  if true
    return @j_del.java_method(:addBodyEndHandler, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |event| yield(nil) unless !block_given? }))
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling add_body_end_handler()"
  end
end
Add a cookie. This will be sent back to the client in the response.

Parameters:

Returns:

  • (self)


170
171
172
173
174
175
176
177
178
179
180
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/routing_context.rb', line 170

def add_cookie(*args)
  if args[0].class.method_defined?(:j_del) && !block_given?
    @j_del.java_method(:addCookie, [Java::IoVertxCoreHttp::Cookie.java_class]).call(args[0].j_del)
    return self
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling add_cookie(#{args[0]})"
  end
end

- (Fixnum) addHeadersEndHandler(handler) { ... }

Add a handler that will be called just before headers are written to the response. This gives you a hook where you can write any extra headers before the response has been written when it will be too late.

Yields:

  • the handler

Returns:

  • (Fixnum)
    the id of the handler. This can be used if you later want to remove the handler.


727
728
729
730
731
732
733
734
735
736
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/routing_context.rb', line 727

def add_headers_end_handler
  if true
    return @j_del.java_method(:addHeadersEndHandler, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |event| yield(nil) unless !block_given? }))
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling add_headers_end_handler()"
  end
end

- (self) attachment(filename)

Set Content-Disposition get to "attachment" with optional filename mime type.

Parameters:

  • filename (String)
    the filename for the attachment

Returns:

  • (self)


620
621
622
623
624
625
626
627
628
629
630
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/routing_context.rb', line 620

def attachment(*args)
  if args[0].class == String && !block_given?
    @j_del.java_method(:attachment, [Java::java.lang.String.java_class]).call(args[0])
    return self
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling attachment(#{args[0]})"
  end
end

- (void) clearUser

This method returns an undefined value.

Clear the current user object in the context. This usually is used for implementing a log out feature, since the current user is unbounded from the routing context.


862
863
864
865
866
867
868
869
870
871
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/routing_context.rb', line 862

def clear_user
  if !block_given?
    return @j_del.java_method(:clearUser, []).call()
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling clear_user()"
  end
end
Returns the number of cookies.

Returns:

  • (Fixnum)
    the number of cookies.


360
361
362
363
364
365
366
367
368
369
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/routing_context.rb', line 360

def cookie_count
  if !block_given?
    return @j_del.java_method(:cookieCount, []).call()
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling cookie_count()"
  end
end
Returns a map of all the cookies.

Returns:



233
234
235
236
237
238
239
240
241
242
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/routing_context.rb', line 233

def cookie_map
  if !block_given?
    return Java::IoVertxLangRuby::Helper.adaptingMap(@j_del.java_method(:cookieMap, []).call(), Proc.new { |val| ::Vertx::Util::Utils.safe_create(val,::Vertx::Cookie) }, Proc.new { |val| val.j_del })
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling cookie_map()"
  end
end

- (::VertxWeb::Route) currentRoute

Returns the current route this context is being routed through.

Returns:



83
84
85
86
87
88
89
90
91
92
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/routing_context.rb', line 83

def current_route
  if !block_given?
    return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:currentRoute, []).call(),::VertxWeb::Route)
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling current_route()"
  end
end

- (::Vertx::Future) end - (::Vertx::Future) end(chunk) - (::Vertx::Future) end(buffer)

Shortcut to the response end.

Overloads:

Returns:



682
683
684
685
686
687
688
689
690
691
692
693
694
695
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/routing_context.rb', line 682

def end(*args)
  if !block_given? && args[0] == nil
    return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:end, []).call(),::Vertx::Future, nil)
  elsif args[0].class == String && !block_given?
    return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:end, [Java::java.lang.String.java_class]).call(args[0]),::Vertx::Future, nil)
  elsif args[0].class.method_defined?(:j_del) && !block_given?
    return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:end, [Java::IoVertxCoreBuffer::Buffer.java_class]).call(args[0].j_del),::Vertx::Future, nil)
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling end(#{args[0]})"
  end
end

- (self) etag(etag)

Set the ETag of a response. This will normalize the quotes if necessary.

etag('md5hashsum'); etag('"md5hashsum"'); ('W/"123456789"');

Parameters:

  • etag (String)
    the etag value

Returns:

  • (self)


421
422
423
424
425
426
427
428
429
430
431
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/routing_context.rb', line 421

def etag(*args)
  if args[0].class == String && !block_given?
    @j_del.java_method(:etag, [Java::java.lang.String.java_class]).call(args[0])
    return self
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling etag(#{args[0]})"
  end
end

- (void) fail(statusCode) - (void) fail(throwable) - (void) fail(statusCode, throwable)

This method returns an undefined value.

Fail the context with the specified throwable and the specified the status code.

This will cause the router to route the context to any matching failure handlers for the request. If no failure handlers match It will trigger the error handler matching the status code. You can define such error handler with VertxWeb::Router#error_handler. If no error handler is not defined, It will send a default failure response with provided status code.

Overloads:

  • - (void) fail(statusCode)

    Parameters:

    • statusCode (Fixnum)
      the HTTP status code
  • - (void) fail(throwable)

    Parameters:

    • throwable (Exception)
      a throwable representing the failure
  • - (void) fail(statusCode, throwable)

    Parameters:

    • statusCode (Fixnum)
      the HTTP status code
    • throwable (Exception)
      a throwable representing the failure


344
345
346
347
348
349
350
351
352
353
354
355
356
357
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/routing_context.rb', line 344

def fail(*args)
  if args[0].class == Fixnum && !block_given? && args[1] == nil
    return @j_del.java_method(:fail, [Java::int.java_class]).call(args[0])
  elsif args[0].is_a?(Exception) && !block_given? && args[1] == nil
    return @j_del.java_method(:fail, [Java::JavaLang::Throwable.java_class]).call(::Vertx::Util::Utils.to_throwable(args[0]))
  elsif args[0].class == Fixnum && args[1].is_a?(Exception) && !block_given?
    return @j_del.java_method(:fail, [Java::int.java_class,Java::JavaLang::Throwable.java_class]).call(args[0],::Vertx::Util::Utils.to_throwable(args[1]))
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling fail(#{args[0]},#{args[1]})"
  end
end

- (true, false) failed

Returns true if the context is being routed to failure handlers.

Returns:

  • (true, false)
    true if the context is being routed to failure handlers.


301
302
303
304
305
306
307
308
309
310
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/routing_context.rb', line 301

def failed?
  if !block_given?
    return @j_del.java_method(:failed, []).call()
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling failed?()"
  end
end

- (Exception) failure

If the context is being routed to failure handlers after a failure has been triggered by calling #fail then this will return that throwable. It can be used by failure handlers to render a response, e.g. create a failure response page.

Returns:

  • (Exception)
    the throwable used when signalling failure


375
376
377
378
379
380
381
382
383
384
385
386
387
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/routing_context.rb', line 375

def failure
  if !block_given?
    if @cached_failure != nil
      return @cached_failure
    end
    return @cached_failure = ::Vertx::Util::Utils.from_throwable(@j_del.java_method(:failure, []).call())
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling failure()"
  end
end

- (Set<::VertxWeb::FileUpload>) fileUploads

Returns a set of fileuploads (if any) for the request. The context must have first been routed to a BodyHandler for this to work.

Returns:



712
713
714
715
716
717
718
719
720
721
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/routing_context.rb', line 712

def file_uploads
  if !block_given?
    return ::Vertx::Util::Utils.to_set(@j_del.java_method(:fileUploads, []).call()).map! { |elt| ::Vertx::Util::Utils.safe_create(elt,::VertxWeb::FileUpload) }
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling file_uploads()"
  end
end

- (true, false) isFresh

Check if the request is fresh, aka Last-Modified and/or the ETag still match.

Returns:

  • (true, false)
    true if content is fresh according to the cache.


221
222
223
224
225
226
227
228
229
230
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/routing_context.rb', line 221

def fresh?
  if !block_given?
    return @j_del.java_method(:isFresh, []).call()
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling fresh?()"
  end
end

- (Object) get(key)

Get some data from the context. The data is available in any handlers that receive the context.

Parameters:

  • key (String)
    the key for the data

Returns:

  • (Object)
    the data


649
650
651
652
653
654
655
656
657
658
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/routing_context.rb', line 649

def get(*args)
  if args[0].class == String && !block_given?
    return ::Vertx::Util::Utils.from_object(@j_del.java_method(:get, [Java::java.lang.String.java_class]).call(args[0]))
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling get(#{args[0]})"
  end
end

- (String) getAcceptableContentType

If the route specifies produces matches, e.g. produces `text/html` and `text/plain`, and the `accept` header matches one or more of these then this returns the most acceptable match.

Returns:

  • (String)
    the most acceptable content type.


819
820
821
822
823
824
825
826
827
828
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/routing_context.rb', line 819

def get_acceptable_content_type
  if !block_given?
    return @j_del.java_method(:getAcceptableContentType, []).call()
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling get_acceptable_content_type()"
  end
end

- (::Vertx::Buffer) getBody

Returns Get the entire HTTP request body as a . The context must have first been routed to a BodyHandler for this to be populated.

Returns:

  • (::Vertx::Buffer)
    Get the entire HTTP request body as a . The context must have first been routed to a BodyHandler for this to be populated.


782
783
784
785
786
787
788
789
790
791
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/routing_context.rb', line 782

def get_body
  if !block_given?
    return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:getBody, []).call(),::Vertx::Buffer)
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling get_body()"
  end
end

- (Hash{String => Object}) getBodyAsJson

Returns Get the entire HTTP request body as a . The context must have first been routed to a BodyHandler for this to be populated.
When the body is null or the "null" JSON literal then null is returned.

Returns:

  • (Hash{String => Object})
    Get the entire HTTP request body as a . The context must have first been routed to a BodyHandler for this to be populated.
    When the body is null or the "null" JSON literal then null is returned.


563
564
565
566
567
568
569
570
571
572
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/routing_context.rb', line 563

def get_body_as_json
  if !block_given?
    return @j_del.java_method(:getBodyAsJson, []).call() != nil ? JSON.parse(@j_del.java_method(:getBodyAsJson, []).call().encode) : nil
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling get_body_as_json()"
  end
end

- (Array<String,Object>) getBodyAsJsonArray

Returns Get the entire HTTP request body as a . The context must have first been routed to a BodyHandler for this to be populated.
When the body is null or the "null" JSON literal then null is returned.

Returns:

  • (Array<String,Object>)
    Get the entire HTTP request body as a . The context must have first been routed to a BodyHandler for this to be populated.
    When the body is null or the "null" JSON literal then null is returned.


112
113
114
115
116
117
118
119
120
121
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/routing_context.rb', line 112

def get_body_as_json_array
  if !block_given?
    return @j_del.java_method(:getBodyAsJsonArray, []).call() != nil ? JSON.parse(@j_del.java_method(:getBodyAsJsonArray, []).call().encode) : nil
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling get_body_as_json_array()"
  end
end

- (String) getBodyAsString - (String) getBodyAsString(encoding)

Get the entire HTTP request body as a string, assuming the specified encoding. The context must have first been routed to a BodyHandler for this to be populated.

Overloads:

  • - (String) getBodyAsString(encoding)

    Parameters:

    • encoding (String)
      the encoding, e.g. "UTF-16"

Returns:

  • (String)
    the body


768
769
770
771
772
773
774
775
776
777
778
779
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/routing_context.rb', line 768

def get_body_as_string(*args)
  if !block_given? && args[0] == nil
    return @j_del.java_method(:getBodyAsString, []).call()
  elsif args[0].class == String && !block_given?
    return @j_del.java_method(:getBodyAsString, [Java::java.lang.String.java_class]).call(args[0])
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling get_body_as_string(#{args[0]})"
  end
end
Get the cookie with the specified name.

Parameters:

  • name (String)
    the cookie name

Returns:



140
141
142
143
144
145
146
147
148
149
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/routing_context.rb', line 140

def get_cookie(*args)
  if args[0].class == String && !block_given?
    return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:getCookie, [Java::java.lang.String.java_class]).call(args[0]),::Vertx::Cookie)
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling get_cookie(#{args[0]})"
  end
end

- (true, false) is(type)

Check if the incoming request contains the "Content-Type" get field, and it contains the give mime `type`. If there is no request body, `false` is returned. If there is no content type, `false` is returned. Otherwise, it returns true if the `type` that matches.

Examples:

// With Content-Type: text/html; charset=utf-8 is("html"); // => true is("text/html"); // => true

// When Content-Type is application/json is("application/json"); // => true is("html"); // => false

Parameters:

  • type (String)
    content type

Returns:

  • (true, false)
    The most close value


286
287
288
289
290
291
292
293
294
295
296
297
298
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/routing_context.rb', line 286

def is?(*args)
  if args[0].class == String && !block_given?
    if @cached_is != nil
      return @cached_is
    end
    return @cached_is = @j_del.java_method(:is, [Java::java.lang.String.java_class]).call(args[0])
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling is?(#{args[0]})"
  end
end

- (::Vertx::Future) json(json)

Encode an Object to JSON and end the request. The method will apply the correct content type to the response, perform the encoding and end.

Parameters:

  • json (Object)
    the json

Returns:



665
666
667
668
669
670
671
672
673
674
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/routing_context.rb', line 665

def json(*args)
  if ::Vertx::Util::unknown_type.accept?(args[0]) && !block_given?
    return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:json, [Java::java.lang.Object.java_class]).call(::Vertx::Util::Utils.to_object(args[0])),::Vertx::Future, nil)
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling json(#{args[0]})"
  end
end

- (self) lastModified(instant)

Set the Last-Modified date using a String.

Parameters:

  • instant (String)
    the last modified instant

Returns:

  • (self)


436
437
438
439
440
441
442
443
444
445
446
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/routing_context.rb', line 436

def last_modified(*args)
  if args[0].class == String && !block_given?
    @j_del.java_method(:lastModified, [Java::java.lang.String.java_class]).call(args[0])
    return self
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling last_modified(#{args[0]})"
  end
end

- (String) mountPoint

Returns the mount point for this router. It will be null for a top level router. For a sub-router it will be the path at which the subrouter was mounted.

Returns:

  • (String)
    the mount point for this router. It will be null for a top level router. For a sub-router it will be the path at which the subrouter was mounted.


245
246
247
248
249
250
251
252
253
254
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/routing_context.rb', line 245

def mount_point
  if !block_given?
    return @j_del.java_method(:mountPoint, []).call()
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling mount_point()"
  end
end

- (void) next

This method returns an undefined value.

Tell the router to route this context to the next matching route (if any). This method, if called, does not need to be called during the execution of the handler, it can be called some arbitrary time later, if required.

If next is not called for a handler then the handler should make sure it ends the response or no response will be sent.



489
490
491
492
493
494
495
496
497
498
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/routing_context.rb', line 489

def next
  if !block_given?
    return @j_del.java_method(:next, []).call()
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling next()"
  end
end

- (String) normalisedPath

Return the normalised path for the request.

The normalised path is where the URI path has been decoded, i.e. any unicode or other illegal URL characters that were encoded in the original URL with `%` will be returned to their original form. E.g. `%20` will revert to a space. Also `+` reverts to a space in a query.

The normalised path will also not contain any `..` character sequences to prevent resources being accessed outside of the permitted area.

It's recommended to always use the normalised path as opposed to if accessing server resources requested by a client.

Returns:

  • (String)
    the normalised path


805
806
807
808
809
810
811
812
813
814
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/routing_context.rb', line 805

def normalised_path
  if !block_given?
    return @j_del.java_method(:normalisedPath, []).call()
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling normalised_path()"
  end
end

- (::VertxWeb::ParsedHeaderValues) parsedHeaders

The headers:
  1. Accept
  2. Accept-Charset
  3. Accept-Encoding
  4. Accept-Language
  5. Content-Type
Parsed into ParsedHeaderValue

Returns:



399
400
401
402
403
404
405
406
407
408
409
410
411
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/routing_context.rb', line 399

def parsed_headers
  if !block_given?
    if @cached_parsed_headers != nil
      return @cached_parsed_headers
    end
    return @cached_parsed_headers = ::Vertx::Util::Utils.safe_create(@j_del.java_method(:parsedHeaders, []).call(),::VertxWeb::ParsedHeaderValues)
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling parsed_headers()"
  end
end

- (String) pathParam(name)

Gets the value of a single path parameter

Parameters:

  • name (String)
    the name of parameter as defined in path declaration

Returns:

  • (String)
    the actual value of the parameter or null if it doesn't exist


592
593
594
595
596
597
598
599
600
601
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/routing_context.rb', line 592

def path_param(*args)
  if args[0].class == String && !block_given?
    return @j_del.java_method(:pathParam, [Java::java.lang.String.java_class]).call(args[0])
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling path_param(#{args[0]})"
  end
end

- (Hash{String => String}) pathParams

Returns a map of named parameters as defined in path declaration with their actual values

Returns:

  • (Hash{String => String})
    the map of named parameters


258
259
260
261
262
263
264
265
266
267
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/routing_context.rb', line 258

def path_params
  if !block_given?
    return Java::IoVertxLangRuby::Helper.adaptingMap(@j_del.java_method(:pathParams, []).call(), Proc.new { |val| val }, Proc.new { |val| ::Vertx::Util::Utils.to_string(val) })
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling path_params()"
  end
end

- (::VertxWeb::LanguageHeader) preferredLanguage

Helper to return the user preferred language. It is the same action as returning the first element of the acceptable languages.

Returns:



518
519
520
521
522
523
524
525
526
527
528
529
530
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/routing_context.rb', line 518

def preferred_language
  if !block_given?
    if @cached_preferred_language != nil
      return @cached_preferred_language
    end
    return @cached_preferred_language = ::Vertx::Util::Utils.safe_create(@j_del.java_method(:preferredLanguage, []).call(),::VertxWeb::LanguageHeader)
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling preferred_language()"
  end
end

- (self) put(key, obj)

Put some arbitrary data in the context. This will be available in any handlers that receive the context.

Parameters:

  • key (String)
    the key for the data
  • obj (Object)
    the data

Returns:

  • (self)


155
156
157
158
159
160
161
162
163
164
165
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/routing_context.rb', line 155

def put(*args)
  if args[0].class == String && ::Vertx::Util::unknown_type.accept?(args[1]) && !block_given?
    @j_del.java_method(:put, [Java::java.lang.String.java_class,Java::java.lang.Object.java_class]).call(args[0],::Vertx::Util::Utils.to_object(args[1]))
    return self
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling put(#{args[0]},#{args[1]})"
  end
end

- (Array<String>) queryParam(name)

Gets the value of a single query parameter. For more info #query_params

Parameters:

  • name (String)
    The name of query parameter

Returns:

  • (Array<String>)
    The list of all parameters matching the parameter name. It returns an empty list if no query parameter with name was found


451
452
453
454
455
456
457
458
459
460
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/routing_context.rb', line 451

def query_param(*args)
  if args[0].class == String && !block_given?
    return @j_del.java_method(:queryParam, [Java::java.lang.String.java_class]).call(args[0]).to_a.map { |elt| elt }
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling query_param(#{args[0]})"
  end
end

- (::Vertx::MultiMap) queryParams

Returns a map of all query parameters inside the query string
The query parameters are lazily decoded: the decoding happens on the first time this method is called. If the query string is invalid it fails the context

Returns:



536
537
538
539
540
541
542
543
544
545
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/routing_context.rb', line 536

def query_params
  if !block_given?
    return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:queryParams, []).call(),::Vertx::MultiMap)
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling query_params()"
  end
end

- (::Vertx::Future) redirect(url)

Perform a 302 redirect to url. If a custom 3xx code is already defined, then that one will be preferred.

The string "back" is special-cased to provide Referrer support, when Referrer is not present "/" is used.

Examples:

redirect('back'); redirect('/login'); redirect('http://google.com');

Parameters:

  • url (String)
    the target url

Returns:



752
753
754
755
756
757
758
759
760
761
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/routing_context.rb', line 752

def redirect(*args)
  if args[0].class == String && !block_given?
    return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:redirect, [Java::java.lang.String.java_class]).call(args[0]),::Vertx::Future, nil)
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling redirect(#{args[0]})"
  end
end

- (Object) remove(key)

Remove some data from the context. The data is available in any handlers that receive the context.

Parameters:

  • key (String)
    the key for the data

Returns:

  • (Object)
    the previous data associated with the key


606
607
608
609
610
611
612
613
614
615
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/routing_context.rb', line 606

def remove(*args)
  if args[0].class == String && !block_given?
    return ::Vertx::Util::Utils.from_object(@j_del.java_method(:remove, [Java::java.lang.String.java_class]).call(args[0]))
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling remove(#{args[0]})"
  end
end

- (true, false) removeBodyEndHandler(handlerID)

Remove a body end handler

Parameters:

Returns:

  • (true, false)
    true if the handler existed and was removed, false otherwise


635
636
637
638
639
640
641
642
643
644
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/routing_context.rb', line 635

def remove_body_end_handler?(*args)
  if args[0].class == Fixnum && !block_given?
    return @j_del.java_method(:removeBodyEndHandler, [Java::int.java_class]).call(args[0])
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling remove_body_end_handler?(#{args[0]})"
  end
end
Remove a cookie from the cookie set. If invalidate is true then it will expire a cookie, notifying a User Agent to remove it from its cookie jar.

Overloads:

  • - (::Vertx::Cookie) removeCookie(name)

    Parameters:

    • name (String)
      the name of the cookie
  • - (::Vertx::Cookie) removeCookie(name, invalidate)

    Parameters:

    • name (String)
      the name of the cookie
    • invalidate (true, false)

Returns:



69
70
71
72
73
74
75
76
77
78
79
80
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/routing_context.rb', line 69

def remove_cookie(*args)
  if args[0].class == String && !block_given? && args[1] == nil
    return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:removeCookie, [Java::java.lang.String.java_class]).call(args[0]),::Vertx::Cookie)
  elsif args[0].class == String && (args[1].class == TrueClass || args[1].class == FalseClass) && !block_given?
    return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:removeCookie, [Java::java.lang.String.java_class,Java::boolean.java_class]).call(args[0],args[1]),::Vertx::Cookie)
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling remove_cookie(#{args[0]},#{args[1]})"
  end
end

- (true, false) removeHeadersEndHandler(handlerID)

Remove a headers end handler

Parameters:

Returns:

  • (true, false)
    true if the handler existed and was removed, false otherwise


876
877
878
879
880
881
882
883
884
885
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/routing_context.rb', line 876

def remove_headers_end_handler?(*args)
  if args[0].class == Fixnum && !block_given?
    return @j_del.java_method(:removeHeadersEndHandler, [Java::int.java_class]).call(args[0])
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling remove_headers_end_handler?(#{args[0]})"
  end
end

- (::Vertx::HttpServerRequest) request

Returns the HTTP request object

Returns:



501
502
503
504
505
506
507
508
509
510
511
512
513
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/routing_context.rb', line 501

def request
  if !block_given?
    if @cached_request != nil
      return @cached_request
    end
    return @cached_request = ::Vertx::Util::Utils.safe_create(@j_del.java_method(:request, []).call(),::Vertx::HttpServerRequest)
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling request()"
  end
end

- (void) reroute(path) - (void) reroute(method, path)

This method returns an undefined value.

Restarts the current router with a new method and path. All path parameters are then parsed and available on the params list. Query params will also be allowed and available.

Overloads:

  • - (void) reroute(path)

    Parameters:

    • path (String)
      the new http path.
  • - (void) reroute(method, path)

    Parameters:

    • method (:OPTIONS, :GET, :HEAD, :POST, :PUT, :DELETE, :TRACE, :CONNECT, :PATCH, :OTHER)
      the new http request
    • path (String)
      the new http path.


319
320
321
322
323
324
325
326
327
328
329
330
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/routing_context.rb', line 319

def reroute(*args)
  if args[0].class == String && !block_given? && args[1] == nil
    return @j_del.java_method(:reroute, [Java::java.lang.String.java_class]).call(args[0])
  elsif args[0].class == Symbol && args[1].class == String && !block_given?
    return @j_del.java_method(:reroute, [Java::IoVertxCoreHttp::HttpMethod.java_class,Java::java.lang.String.java_class]).call(Java::IoVertxCoreHttp::HttpMethod.valueOf(args[0].to_s),args[1])
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling reroute(#{args[0]},#{args[1]})"
  end
end

- (::Vertx::HttpServerResponse) response

Returns the HTTP response object

Returns:



845
846
847
848
849
850
851
852
853
854
855
856
857
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/routing_context.rb', line 845

def response
  if !block_given?
    if @cached_response != nil
      return @cached_response
    end
    return @cached_response = ::Vertx::Util::Utils.safe_create(@j_del.java_method(:response, []).call(),::Vertx::HttpServerResponse)
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling response()"
  end
end

- (::VertxWeb::Session) session

Get the session. The context must have first been routed to a SessionHandler for this to be populated. Sessions live for a browser session, and are maintained by session cookies.

Returns:



551
552
553
554
555
556
557
558
559
560
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/routing_context.rb', line 551

def session
  if !block_given?
    return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:session, []).call(),::VertxWeb::Session)
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling session()"
  end
end

- (void) setAcceptableContentType(contentType)

This method returns an undefined value.

Set the acceptable content type. Used by

Parameters:

  • contentType (String)
    the content type


126
127
128
129
130
131
132
133
134
135
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/routing_context.rb', line 126

def set_acceptable_content_type(*args)
  if args[0].class == String && !block_given?
    return @j_del.java_method(:setAcceptableContentType, [Java::java.lang.String.java_class]).call(args[0])
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling set_acceptable_content_type(#{args[0]})"
  end
end

- (void) setBody(body)

This method returns an undefined value.

Set the body. Used by the BodyHandler. You will not normally call this method.

Parameters:



833
834
835
836
837
838
839
840
841
842
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/routing_context.rb', line 833

def set_body(*args)
  if args[0].class.method_defined?(:j_del) && !block_given?
    return @j_del.java_method(:setBody, [Java::IoVertxCoreBuffer::Buffer.java_class]).call(args[0].j_del)
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling set_body(#{args[0]})"
  end
end

- (void) setSession(session)

This method returns an undefined value.

Set the session. Used by the SessionHandler. You will not normally call this method.

Parameters:



700
701
702
703
704
705
706
707
708
709
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/routing_context.rb', line 700

def set_session(*args)
  if args[0].class.method_defined?(:j_del) && !block_given?
    return @j_del.java_method(:setSession, [Java::IoVertxExtWeb::Session.java_class]).call(args[0].j_del)
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling set_session(#{args[0]})"
  end
end

- (void) setUser(user)

This method returns an undefined value.

Set the user. Usually used by auth handlers to inject a User. You will not normally call this method.

Parameters:



206
207
208
209
210
211
212
213
214
215
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/routing_context.rb', line 206

def set_user(*args)
  if args[0].class.method_defined?(:j_del) && !block_given?
    return @j_del.java_method(:setUser, [Java::IoVertxExtAuth::User.java_class]).call(args[0].j_del)
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling set_user(#{args[0]})"
  end
end

- (Fixnum) statusCode

If the context is being routed to failure handlers after a failure has been triggered by calling #fail then this will return that status code. It can be used by failure handlers to render a response, e.g. create a failure response page. When the status code has not been set yet (it is undefined) its value will be -1.

Returns:

  • (Fixnum)
    the status code used when signalling failure


468
469
470
471
472
473
474
475
476
477
478
479
480
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/routing_context.rb', line 468

def status_code
  if !block_given?
    if @cached_status_code != nil
      return @cached_status_code
    end
    return @cached_status_code = @j_del.java_method(:statusCode, []).call()
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling status_code()"
  end
end

- (::VertxAuthCommon::User) user

Get the authenticated user (if any). This will usually be injected by an auth handler if authentication if successful.

Returns:



889
890
891
892
893
894
895
896
897
898
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/routing_context.rb', line 889

def user
  if !block_given?
    return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:user, []).call(),::VertxAuthCommon::User)
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling user()"
  end
end

- (::Vertx::Vertx) vertx

Returns the Vert.x instance associated to the initiating VertxWeb::Router for this context

Returns:



575
576
577
578
579
580
581
582
583
584
585
586
587
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/routing_context.rb', line 575

def vertx
  if !block_given?
    if @cached_vertx != nil
      return @cached_vertx
    end
    return @cached_vertx = ::Vertx::Util::Utils.safe_create(@j_del.java_method(:vertx, []).call(),::Vertx::Vertx)
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling vertx()"
  end
end