Class: VertxWebClient::HttpRequestTemplate
- Inherits:
-
Object
- Object
- VertxWebClient::HttpRequestTemplate
- Defined in:
- /Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web-client/http_request_template.rb
Overview
Instances are created by an instance, via one of the methods createXXX
corresponding to the
specific HTTP methods.
The request template shall be configured prior making a request, the template is immutable and when a configuration method is called, a new template is returned allowing to expose the template and apply further customization.
After the request template has been configured, the methods
can be called.
The #bufferBody
configures the template to buffer the entire HTTP response body and returns a
HttpResponseTemplate for configuring the response body.
The send
methods perform the actual request, they can be used multiple times to perform HTTP requests.
Constant Summary
- @@j_api_type =
Object.new
Class Method Summary (collapse)
- + (Boolean) accept?(obj)
- + (Object) j_api_type
- + (Object) j_class
- + (Object) unwrap(obj)
- + (Object) wrap(obj)
Instance Method Summary (collapse)
-
- (::VertxWebClient::HttpResponseTemplate) buffer_body
Configure to buffer the body and returns a HttpResponseTemplate for further configuration of the response or sending the request.
-
- (::VertxWebClient::HttpRequestTemplate) host(value = nil)
Configure the template to use a new host value.
-
- (::VertxWebClient::HttpRequestTemplate) method(value = nil)
Configure the template to use a new method value.
-
- (::VertxWebClient::HttpRequestTemplate) port(value = nil)
Configure the template to use a new port value.
-
- (::VertxWebClient::HttpRequestTemplate) put_header(name = nil, value = nil)
Configure the template to add a new HTTP header.
-
- (::VertxWebClient::HttpRequestTemplate) request_uri(value = nil)
Configure the template to use a new request URI value.
-
- (void) send { ... }
Send a request, the handler will receive the response as an .
-
- (void) send_buffer(body = nil) { ... }
Like #send but with an HTTP request body buffer.
-
- (void) send_json(body = nil) { ... }
Like #send but with an HTTP request body object encoded as json and the content type set to application/json.
-
- (void) send_stream(body = nil) { ... }
Like #send but with an HTTP request body stream.
-
- (::VertxWebClient::HttpRequestTemplate) timeout(value = nil)
Configures the amount of time in milliseconds after which if the request does not return any data within the timeout period an TimeoutException fails the request.
Class Method Details
+ (Boolean) accept?(obj)
40 41 42 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web-client/http_request_template.rb', line 40 def @@j_api_type.accept?(obj) obj.class == HttpRequestTemplate end |
+ (Object) j_api_type
49 50 51 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web-client/http_request_template.rb', line 49 def self.j_api_type @@j_api_type end |
+ (Object) j_class
52 53 54 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web-client/http_request_template.rb', line 52 def self.j_class Java::IoVertxWebclient::HttpRequestTemplate.java_class end |
+ (Object) unwrap(obj)
46 47 48 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web-client/http_request_template.rb', line 46 def @@j_api_type.unwrap(obj) obj.j_del end |
+ (Object) wrap(obj)
43 44 45 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web-client/http_request_template.rb', line 43 def @@j_api_type.wrap(obj) HttpRequestTemplate.new(obj) end |
Instance Method Details
- (::VertxWebClient::HttpResponseTemplate) buffer_body
156 157 158 159 160 161 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web-client/http_request_template.rb', line 156 def buffer_body if !block_given? return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:receiveBody, []).call(), ::VertxWebClient::HttpResponseTemplate, ::Vertx::Buffer.j_api_type) end raise ArgumentError, "Invalid arguments when calling buffer_body()" end |
- (::VertxWebClient::HttpRequestTemplate) host(value = nil)
value
.
76 77 78 79 80 81 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web-client/http_request_template.rb', line 76 def host(value=nil) if value.class == String && !block_given? return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:host, [Java::java.lang.String.java_class]).call(value),::VertxWebClient::HttpRequestTemplate) end raise ArgumentError, "Invalid arguments when calling host(#{value})" end |
- (::VertxWebClient::HttpRequestTemplate) method(value = nil)
value
.
58 59 60 61 62 63 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web-client/http_request_template.rb', line 58 def method(value=nil) if value.class == Symbol && !block_given? return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:method, [Java::IoVertxCoreHttp::HttpMethod.java_class]).call(Java::IoVertxCoreHttp::HttpMethod.valueOf(value)),::VertxWebClient::HttpRequestTemplate) end raise ArgumentError, "Invalid arguments when calling method(#{value})" end |
- (::VertxWebClient::HttpRequestTemplate) port(value = nil)
value
.
67 68 69 70 71 72 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web-client/http_request_template.rb', line 67 def port(value=nil) if value.class == Fixnum && !block_given? return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:port, [Java::int.java_class]).call(value),::VertxWebClient::HttpRequestTemplate) end raise ArgumentError, "Invalid arguments when calling port(#{value})" end |
- (::VertxWebClient::HttpRequestTemplate) put_header(name = nil, value = nil)
95 96 97 98 99 100 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web-client/http_request_template.rb', line 95 def put_header(name=nil,value=nil) if name.class == String && value.class == String && !block_given? return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:putHeader, [Java::java.lang.String.java_class,Java::java.lang.String.java_class]).call(name,value),::VertxWebClient::HttpRequestTemplate) end raise ArgumentError, "Invalid arguments when calling put_header(#{name},#{value})" end |
- (::VertxWebClient::HttpRequestTemplate) request_uri(value = nil)
value
.
85 86 87 88 89 90 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web-client/http_request_template.rb', line 85 def request_uri(value=nil) if value.class == String && !block_given? return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:uri, [Java::java.lang.String.java_class]).call(value), ::VertxWebClient::HttpRequestTemplate) end raise ArgumentError, "Invalid arguments when calling request_uri(#{value})" end |
- (void) send { ... }
This method returns an undefined value.
Send a request, thehandler
will receive the response as an .
147 148 149 150 151 152 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web-client/http_request_template.rb', line 147 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) { ... }
127 128 129 130 131 132 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web-client/http_request_template.rb', line 127 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 requestbody
object encoded as json and the content type
set to application/json
.
138 139 140 141 142 143 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web-client/http_request_template.rb', line 138 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) { ... }
117 118 119 120 121 122 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web-client/http_request_template.rb', line 117 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 |
- (::VertxWebClient::HttpRequestTemplate) timeout(value = nil)
Setting zero or a negative value
disables the timeout.
107 108 109 110 111 112 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web-client/http_request_template.rb', line 107 def timeout(value=nil) if value.class == Fixnum && !block_given? return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:timeout, [Java::long.java_class]).call(value),::VertxWebClient::HttpRequestTemplate) end raise ArgumentError, "Invalid arguments when calling timeout(#{value})" end |