Class: VertxWebCodec::BodyCodec

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

Overview

A codec for encoding and decoding HTTP bodies.

Class Method Summary (collapse)

Class Method Details

+ (::VertxWebCodec::BodyCodec) buffer

Returns the codec

Returns:

Raises:

  • (ArgumentError)


31
32
33
34
35
36
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web-codec/body_codec.rb', line 31

def self.buffer
  if !block_given?
    return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtWebCodec::BodyCodec.java_method(:buffer, []).call(),::VertxWebCodec::BodyCodec,::Vertx::Buffer.j_api_type)
  end
  raise ArgumentError, "Invalid arguments when calling buffer()"
end

+ (::VertxWebCodec::BodyCodec) create(decode = nil) { ... }

Create a codec that buffers the entire body and then apply the decode function and returns the result.

Yields:

  • the decode function

Returns:

Raises:

  • (ArgumentError)


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

def self.create(decode=nil)
  if block_given? && decode == nil
    return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtWebCodec::BodyCodec.java_method(:create, [Java::JavaUtilFunction::Function.java_class]).call((Proc.new { |event| ::Vertx::Util::Utils.to_object(yield(::Vertx::Util::Utils.safe_create(event,::Vertx::Buffer))) })),::VertxWebCodec::BodyCodec, nil)
  end
  raise ArgumentError, "Invalid arguments when calling create(#{decode})"
end

+ (::VertxWebCodec::BodyCodec) json_object

Returns the codec

Returns:

Raises:

  • (ArgumentError)


38
39
40
41
42
43
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web-codec/body_codec.rb', line 38

def self.json_object
  if !block_given?
    return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtWebCodec::BodyCodec.java_method(:jsonObject, []).call(),::VertxWebCodec::BodyCodec, nil)
  end
  raise ArgumentError, "Invalid arguments when calling json_object()"
end

+ (::VertxWebCodec::BodyCodec) none

Returns a codec that simply discards the response

Returns:

Raises:

  • (ArgumentError)


45
46
47
48
49
50
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web-codec/body_codec.rb', line 45

def self.none
  if !block_given?
    return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtWebCodec::BodyCodec.java_method(:none, []).call(),::VertxWebCodec::BodyCodec, nil)
  end
  raise ArgumentError, "Invalid arguments when calling none()"
end

+ (::VertxWebCodec::BodyCodec) pipe(stream = nil)

A body codec that pipes the body to a write stream.

Parameters:

Returns:

Raises:

  • (ArgumentError)


63
64
65
66
67
68
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web-codec/body_codec.rb', line 63

def self.pipe(stream=nil)
  if stream.class.method_defined?(:j_del) && !block_given?
    return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtWebCodec::BodyCodec.java_method(:pipe, [Java::IoVertxCoreStreams::WriteStream.java_class]).call(stream.j_del),::VertxWebCodec::BodyCodec, nil)
  end
  raise ArgumentError, "Invalid arguments when calling pipe(#{stream})"
end

+ (::VertxWebCodec::BodyCodec) string(encoding = nil)

A codec for strings using a specific encoding.

Parameters:

  • encoding (String) (defaults to: nil)
    the encoding

Returns:

Raises:

  • (ArgumentError)


22
23
24
25
26
27
28
29
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web-codec/body_codec.rb', line 22

def self.string(encoding=nil)
  if !block_given? && encoding == nil
    return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtWebCodec::BodyCodec.java_method(:string, []).call(),::VertxWebCodec::BodyCodec, nil)
  elsif encoding.class == String && !block_given?
    return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtWebCodec::BodyCodec.java_method(:string, [Java::java.lang.String.java_class]).call(encoding),::VertxWebCodec::BodyCodec, nil)
  end
  raise ArgumentError, "Invalid arguments when calling string(#{encoding})"
end