Class: VertxWebClient::HttpResponseTemplate

Inherits:
Object
  • Object
show all
Defined in:
/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web-client/http_response_template.rb

Overview

A template for configuring client-side HTTP responses.

Instance Method Summary (collapse)

Instance Method Details

- (::VertxWebClient::HttpResponseTemplate) as_json_object

Configure the template to decode the response as a Json object.

Returns:

Raises:

  • (ArgumentError)


73
74
75
76
77
78
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web-client/http_response_template.rb', line 73

def as_json_object
  if !block_given?
    return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:asJsonObject, []).call(),::VertxWebClient::HttpResponseTemplate, nil)
  end
  raise ArgumentError, "Invalid arguments when calling as_json_object()"
end

- (::VertxWebClient::HttpResponseTemplate) as_string(encoding = nil)

Like #as_string but with the specified encoding param.

Parameters:

  • encoding (String) (defaults to: nil)

Returns:

Raises:

  • (ArgumentError)


63
64
65
66
67
68
69
70
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web-client/http_response_template.rb', line 63

def as_string(encoding=nil)
  if !block_given? && encoding == nil
    return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:asString, []).call(),::VertxWebClient::HttpResponseTemplate, nil)
  elsif encoding.class == String && !block_given?
    return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:asString, [Java::java.lang.String.java_class]).call(encoding),::VertxWebClient::HttpResponseTemplate, nil)
  end
  raise ArgumentError, "Invalid arguments when calling as_string(#{encoding})"
end

- (void) send { ... }

This method returns an undefined value.

Send a request, the handler will receive the response as an VertxWebClient::HttpResponse.

Yields:

Raises:

  • (ArgumentError)


23
24
25
26
27
28
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web-client/http_response_template.rb', line 23

def send
  if block_given?
    return @j_del.java_method(:send, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::VertxWebClient::HttpResponse, nil) : nil) }))
  end
  raise ArgumentError, "Invalid arguments when calling send()"
end

- (void) send_buffer(body = nil) { ... }

This method returns an undefined value.

Like #send but with an HTTP request body buffer.

Parameters:

Yields:

Raises:

  • (ArgumentError)


43
44
45
46
47
48
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web-client/http_response_template.rb', line 43

def send_buffer(body=nil)
  if body.class.method_defined?(:j_del) && block_given?
    return @j_del.java_method(:sendBuffer, [Java::IoVertxCoreBuffer::Buffer.java_class, Java::IoVertxCore::Handler.java_class]).call(body.j_del, (Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result, ::VertxWebClient::HttpResponse, nil) : nil) }))
  end
  raise ArgumentError, "Invalid arguments when calling send_buffer(#{body})"
end

- (void) send_json(body = nil) { ... }

This method returns an undefined value.

Like #send but with an HTTP request body json and the content type set to application/json.

Parameters:

  • body (Object) (defaults to: nil)
    the body

Yields:

Raises:

  • (ArgumentError)


54
55
56
57
58
59
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web-client/http_response_template.rb', line 54

def send_json(body=nil)
  if ::Vertx::Util::unknown_type.accept?(body) && block_given?
    return @j_del.java_method(:sendJsonPOJO, [Java::java.lang.Object.java_class, Java::IoVertxCore::Handler.java_class]).call(::Vertx::Util::Utils.to_object(body), (Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result, ::VertxWebClient::HttpResponse, nil) : nil) }))
  end
  raise ArgumentError, "Invalid arguments when calling send_json(#{body})"
end

- (void) send_stream(body = nil) { ... }

This method returns an undefined value.

Like #send but with an HTTP request body stream.

Parameters:

Yields:

Raises:

  • (ArgumentError)


33
34
35
36
37
38
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web-client/http_response_template.rb', line 33

def send_stream(body=nil)
  if body.class.method_defined?(:j_del) && block_given?
    return @j_del.java_method(:sendStream, [Java::IoVertxCoreStreams::ReadStream.java_class,Java::IoVertxCore::Handler.java_class]).call(body.j_del,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::VertxWebClient::HttpResponse, nil) : nil) }))
  end
  raise ArgumentError, "Invalid arguments when calling send_stream(#{body})"
end