TextResponse - viames/pair GitHub Wiki

Pair framework: TextResponse

Pair\Http\TextResponse is the explicit plain-text response object for Pair v4.

Use it when an endpoint must return raw text instead of JSON or HTML, for example webhook challenge handshakes.

Constructor

new TextResponse(string $content, int $httpCode = 200, string $contentType = 'text/plain; charset=utf-8')

Arguments:

  • content: response body
  • httpCode: HTTP status code
  • contentType: response content type header

Example:

use Pair\Http\TextResponse;

return new TextResponse('challenge-token');

Notes

  • send() sets the Content-Type header and the HTTP status code, then prints the text body.
  • When APP_DEBUG=true and observability debug headers are enabled, send() also emits Pair correlation and trace timing headers.
  • TextResponse implements Pair\Http\ResponseInterface, so it works with the same runtime dispatch path as JsonResponse and PageResponse.

See also: API, ApiController, Controller, ResponseInterface, ApiErrorResponse, Observability, EmptyResponse.