NAME

Thunderhorse::Response - Response wrapper for Thunderhorse

SYNOPSIS

async sub show ($self, $ctx, $id)
{
	$ctx->res->text("Hello World");
	$ctx->res->json({data => 'value'});
	$ctx->res->redirect('/login');
}

DESCRIPTION

Thunderhorse::Response is a thin wrapper around PAGI::Response that integrates with Thunderhorse::Context. It provides a fluent interface for building HTTP responses, including JSON, HTML, redirects, and file downloads.

This class extends PAGI::Response and mixes in Thunderhorse::Message to provide context integration.

INTERFACE

Inherits all interface from PAGI::Response, and adds the interface documented below.

Attributes

context

The Thunderhorse::Context object for this request (weakened).

Required in the constructor

Methods

new

$object = $class->new(%args)

Standard Mooish constructor. Consult "Attributes" section for available constructor arguments.

update

$res->update($scope, $receive, $send)

Updates the internal PAGI scope. Called automatically when the context's PAGI tuple changes via setter of "pagi" in Thunderhorse::Context.

is_ready

$bool = $res->is_ready()

Returns whether this response is ready as far as Thunderhorse is concerned. Responses which are ready will cause the context to become consumed after the route handler returns.

Response is ready if it has a body, or if it has a status which does not require body like 204 No Content or 3XX.

SEE ALSO

Thunderhorse, PAGI::Response, Thunderhorse::Context