NAME
Punk::Response - a response builder
SYNOPSIS
$c->status(201);
$c->header('X-Request-Id' => $rid);
return { id => $id }; # builder state folds into the JSON
return Punk::Response->new(
status => 201, body => { id => $id }); # or explicitly
DESCRIPTION
The mutable half of the response path. Most handlers never touch it - they return data, a finished triplet, or use the Punk::Context builders - but $c->res gives full control when needed, and a returned Punk::Response is finalized by the dispatcher.
The object is a plain blessed array with an all-C implementation; reference bodies JSON-encode through File::Raw::JSON's C ABI at finalize. Load through Punk, which loads the compiled core first.
METHODS
new(%args)
status, headers (arrayref of pairs, kept live), body, type. Unknown options croak.
status
type
body
Get/set; setters chain.
header
header(Name => $value) appends and chains; header('Name') reads (case-insensitive, first match).
headers
The live header pair arrayref.
finalize
The PSGI triplet: a reference body is JSON-encoded (application/json) through the File::Raw::JSON C ABI, a string is text/html unless "type" says otherwise, no body is a text/plain empty 200; Content-Length always set.
AUTHOR
LNATION <email@lnation.org>
LICENSE AND COPYRIGHT
This software is Copyright (c) 2026 by LNATION <email@lnation.org>.
This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)