gossamer/response

Types

This Fetch API interface represents the response to a request.

pub type Response

Values

pub fn array_buffer(
  response: Response,
) -> promise.Promise(array_buffer.ArrayBuffer)

Takes a Response stream and reads it to completion. It returns a promise that resolves with an ArrayBuffer.

pub fn body(
  response: Response,
) -> option.Option(
  readable_stream.ReadableStream(uint8_array.Uint8Array),
)

A simple getter used to expose a ReadableStream of the body contents.

pub fn body_used(response: Response) -> Bool

Stores a Boolean that declares whether the body has been used in a response yet.

pub fn bytes(
  response: Response,
) -> promise.Promise(uint8_array.Uint8Array)

Takes a Response stream and reads it to completion. It returns a promise that resolves with a Uint8Array.

pub fn clone(response: Response) -> Response
pub fn error() -> Response
pub fn headers(response: Response) -> headers.Headers
pub fn json(
  data: dynamic.Dynamic,
  init: List(response_init.ResponseInit),
) -> Response
pub fn json_body(
  response: Response,
) -> promise.Promise(dynamic.Dynamic)

Takes a Response stream and reads it to completion. It returns a promise that resolves with the result of parsing the body text as JSON.

pub fn new(body: String) -> Response
pub fn new_with_init(
  body: String,
  init: List(response_init.ResponseInit),
) -> Response
pub fn ok(response: Response) -> Bool
pub fn redirect(url: String) -> Response
pub fn redirect_with_status(url: String, status: Int) -> Response
pub fn redirected(response: Response) -> Bool
pub fn status(response: Response) -> Int
pub fn status_text(response: Response) -> String
pub fn text(response: Response) -> promise.Promise(String)

Takes a Response stream and reads it to completion. It returns a promise that resolves with a USVString (text).

pub fn type_(response: Response) -> String
pub fn url(response: Response) -> String
Search Document