API / Minn\Rest / Reply

Reply final class

Minn\Rest\Reply · public/minn/src/Minn/Rest/Reply.php · 53 lines

JSON responses in the reference's shape: its header set, its json_encode flags (slashes escaped), the _fields filter, and the pagination headers on lists.

Constants and properties

constHEADERS = array ( 'Content-Type' => 'application/json; charset=UTF-8', 'X-Content-Type-Options' => 'nosniff', 'Access-Control-Expose-Headers' => 'X-WP-Total, X-WP-TotalPages, Link', 'Access-Control-Allow-Headers' => 'Authorization, X-WP-Nonce, Content-Disposition, Content-MD5, Content-Type', )

Public

staticanswer(Minn\Http\Request $request, mixed $data, int $status = 200): Minn\Http\Response#

One item, shaped by the request's own _fields: what nearly every handler ends with.

staticitem(mixed $data, ?Minn\Rest\Fields $fields, int $status = 200): Minn\Http\Response#

One object as a response, the selected fields applied.

staticalternate(Minn\Http\Response $response, string $permalink): Minn\Http\Response#

A post's answer pointing at its page on the site, as a viewable type's single item does.

staticlist(array $rows, int $total, int $totalPages, ?Minn\Rest\Fields $fields): Minn\Http\Response#

A list response with the total and page-count headers.

$rowslist<array>
staticerror(Minn\RestError $error): Minn\Http\Response#

A REST error as the reference's error body.