PhoenixGenApi.Structs.Response (PhoenixGenApi v2.11.0)

Copy Markdown View Source

Defines the structure of a response sent back to the client.

This module provides helper functions to create different types of responses, such as synchronous, asynchronous, and error responses.

Summary

Functions

Creates a response for an asynchronous request, indicating that the request has been received and is being processed.

Create Request from params for convert data map from websocket api.

Create Request from params for convert data map from websocket api. Opts is not supported yet.

Creates a response for a failed request.

Checks if the response represents an error.

Creates a response to indicate the end of a stream.

Creates a response for a streaming request.

Creates a response for a successful synchronous request.

Types

t()

@type t() :: %PhoenixGenApi.Structs.Response{
  async: boolean(),
  can_retry: boolean(),
  error: String.t() | nil,
  has_more: boolean(),
  request_id: String.t(),
  result: any(),
  success: boolean()
}

Functions

async_response(request_id)

Creates a response for an asynchronous request, indicating that the request has been received and is being processed.

encode(res, opts)

encode!(res)

Create Request from params for convert data map from websocket api.

encode!(res, opts)

Create Request from params for convert data map from websocket api. Opts is not supported yet.

error_response(request_id, error, can_retry \\ false)

Creates a response for a failed request.

is_error?(response)

Checks if the response represents an error.

stream_end_response(request_id)

Creates a response to indicate the end of a stream.

stream_response(request_id, result, has_more \\ true)

Creates a response for a streaming request.

sync_response(request_id, result)

Creates a response for a successful synchronous request.