NAME

PAGI::FastAPI::Response::HTML - HTML Response Class for PAGI::FastAPI

VERSION

Version v1.0.0

SYNOPSIS

use PAGI::FastAPI::Response::HTML;

# Direct construction
my $res = PAGI::FastAPI::Response::HTML->new(
    body   => '<h1>Hello World</h1>',
    status => 200,
);

# Or via Context helper method inside route handlers
$app->get('/', handler => async sub ($c) {
    return $c->html('<h1>Welcome</h1>');
});

DESCRIPTION

PAGI::FastAPI::Response::HTML handles HTTP responses with a Content-Type of text/html; charset=utf-8.

CONSTRUCTOR

new(%options)

  • body (Optional)

    The HTML string body. Defaults to an empty string.

  • status (Optional)

    HTTP status code integer. Defaults to 200.

  • headers (Optional)

    ArrayRef of additional header key-value pairs (e.g., [ ['X-Frame-Options' => 'DENY'] ]).

METHODS

send($c, $pagi_writer)

Applies status code, sets the Content-Type header to text/html; charset=utf-8, and writes the HTML body string asynchronously to the response stream writer.

SEE ALSO

PAGI::FastAPI::Context, PAGI::FastAPI

AUTHOR

Mohammad Sajid Anwar, <mohammad.anwar at yahoo.com>

REPOSITORY

https://github.com/manwar/PAGI-FastAPI

BUGS

Please report any bugs or feature requests through the web interface at https://github.com/manwar/PAGI-FastAPI/issues. I will be notified and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

perldoc PAGI::FastAPI::Response::HTML

You can also look for information at:

LICENSE AND COPYRIGHT

Copyright (C) 2026 Mohammad Sajid Anwar.

This program is free software; you can redistribute it and/or modify it under the terms of the Artistic License (2.0).