| 1 | package PAGI::FastAPI::Response; | ||
| 2 | |||
| 3 | 27 | ▶ | use v5.38; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 27 | ▶ | use experimental 'class'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | 27 | ▶ | use version; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | |||
| 7 | 27 | our $VERSION = qv('v1.7.3'); | |
| 8 | 27 | our $AUTHORITY = 'cpan:MANWAR'; | |
| 9 | |||
| 10 | 27 | ▶ | use Future::AsyncAwait; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 11 | |||
| 12 | 27 | class PAGI::FastAPI::Response { | |
| 13 | 27 | field $body :param = ''; | |
| 14 | 27 | field $status :param = 200; | |
| 15 | 27 | field $headers :param = []; | |
| 16 | |||
| 17 | 8 | ▶ | method body () { return $body } |
|
Subroutine
body: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 18 | 2 | ▶ | method status () { return $status } |
|
Subroutine
status: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 19 | 2 | ▶ | method headers () { return $headers } |
|
Subroutine
headers: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 20 | |||
| 21 | 23 | ▶ | method prepare_headers ($c, $default_content_type = 'text/html; charset=utf-8') { |
|
Subroutine
prepare_headers: called CC=3 SCAR=11.0
Pod
undocumented
| |||
| 22 | 23 | $c->status($status); | |
| 23 | |||
| 24 | # Set default content type | ||
| 25 | 23 | $c->set_header('content-type' => $default_content_type); | |
| 26 | |||
| 27 | 23 | for my $header (@$headers) { | |
| 28 | 16 | $c->set_header(lc($header->[0]) => $header->[1]); | |
| 29 | } | ||
| 30 | 27 | } | |
| 31 | |||
| 32 | 0 | ▶ | method TO_JSON () { |
|
Subroutine
TO_JSON: not called CC=1 SCAR=6.9
Pod
undocumented
| |||
| 33 | 0 | return $body; | |
| 34 | 27 | } | |
| 35 | } | ||
| 36 | |||
| 37 | =encoding utf-8 | ||
| 38 | |||
| 39 | =head1 NAME | ||
| 40 | |||
| 41 | PAGI::FastAPI::Response - Base HTTP Response Class for PAGI::FastAPI | ||
| 42 | |||
| 43 | =head1 VERSION | ||
| 44 | |||
| 45 | Version v1.7.3 | ||
| 46 | |||
| 47 | =head1 SYNOPSIS | ||
| 48 | |||
| 49 | use PAGI::FastAPI::Response; | ||
| 50 | |||
| 51 | my $res = PAGI::FastAPI::Response->new( | ||
| 52 | body => 'Plain text content', | ||
| 53 | status => 200, | ||
| 54 | ); | ||
| 55 | |||
| 56 | =head1 DESCRIPTION | ||
| 57 | |||
| 58 | C<PAGI::FastAPI::Response> serves as the base class for specialised HTTP | ||
| 59 | responses in L<PAGI::FastAPI> (such as L<PAGI::FastAPI::Response::HTML> and | ||
| 60 | L<PAGI::FastAPI::Response::SSE>). | ||
| 61 | |||
| 62 | =head1 SEE ALSO | ||
| 63 | |||
| 64 | L<PAGI::FastAPI::Response::HTML>, L<PAGI::FastAPI::Response::SSE> | ||
| 65 | |||
| 66 | =head1 AUTHOR | ||
| 67 | |||
| 68 | Mohammad Sajid Anwar, C<< <mohammad.anwar at yahoo.com> >> | ||
| 69 | |||
| 70 | =head1 REPOSITORY | ||
| 71 | |||
| 72 | L<https://github.com/manwar/PAGI-FastAPI> | ||
| 73 | |||
| 74 | =head1 BUGS | ||
| 75 | |||
| 76 | Please report any bugs or feature requests through the web interface at L<https://github.com/manwar/PAGI-FastAPI/issues>. | ||
| 77 | I will be notified and then you'll automatically be notified of progress on your | ||
| 78 | bug as I make changes. | ||
| 79 | |||
| 80 | =head1 SUPPORT | ||
| 81 | |||
| 82 | You can find documentation for this module with the perldoc command. | ||
| 83 | |||
| 84 | perldoc PAGI::FastAPI::Response | ||
| 85 | |||
| 86 | You can also look for information at: | ||
| 87 | |||
| 88 | =over 4 | ||
| 89 | |||
| 90 | =item * BUG Report | ||
| 91 | |||
| 92 | L<https://github.com/manwar/PAGI-FastAPI/issues> | ||
| 93 | |||
| 94 | =item * Search MetaCPAN | ||
| 95 | |||
| 96 | L<https://metacpan.org/dist/PAGI-FastAPI/> | ||
| 97 | |||
| 98 | =back | ||
| 99 | |||
| 100 | =head1 LICENSE AND COPYRIGHT | ||
| 101 | |||
| 102 | Copyright (C) 2026 Mohammad Sajid Anwar. | ||
| 103 | |||
| 104 | This program is free software; you can redistribute it and/or modify it under | ||
| 105 | the terms of the Artistic License (2.0). | ||
| 106 | |||
| 107 | =cut | ||
| 108 | |||
| 109 | 27 | 1; # End of PAGI::FastAPI::Response | |