Class: Rack::WASI::OutgoingResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/rack/wasi/incoming_handler.rb

Overview

resource outgoing-response {

  constructor(headers: headers);
  status-code: func() -> status-code;
  set-status-code: func(status-code: status-code) -> result;
  headers: func() -> headers;
  body: func() -> result<outgoing-body>;
}

resource outgoing-body {
  write: func() -> result<output-stream>;
  finish: static func(
      this: outgoing-body,
      trailers: option<trailers>
    ) -> result<_, error-code>;
  }
}

github.com/WebAssembly/wasi-http/blob/d163277b8684483a2334363ca1492ca298ea526d/wit/types.wit#L572

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(headers:, status_code: 200) ⇒ OutgoingResponse

Returns a new instance of OutgoingResponse.



113
114
115
116
117
# File 'lib/rack/wasi/incoming_handler.rb', line 113

def initialize(headers:, status_code: 200)
  @headers = headers
  @status_code = status_code
  @body = nil
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



111
112
113
# File 'lib/rack/wasi/incoming_handler.rb', line 111

def body
  @body
end

#headersObject (readonly)

Returns the value of attribute headers.



111
112
113
# File 'lib/rack/wasi/incoming_handler.rb', line 111

def headers
  @headers
end

#status_codeObject (readonly)

Returns the value of attribute status_code.



111
112
113
# File 'lib/rack/wasi/incoming_handler.rb', line 111

def status_code
  @status_code
end

Instance Method Details

#write(response_body) ⇒ Object



119
120
121
# File 'lib/rack/wasi/incoming_handler.rb', line 119

def write(response_body)
  @body = response_body
end