NAME
PAGI::FastAPI::Response::Redirect - HTTP Redirect Response for PAGI::FastAPI
VERSION
Version v1.2.5
SYNOPSIS
use PAGI::FastAPI::Response::Redirect qw(redirect_to);
$app->get('/old-path',
handler => async sub ($c) {
return redirect_to('/new-path'); # defaults to 302
}
);
$app->get('/permanent-move',
handler => async sub ($c) {
return redirect_to('/new-path', status => 301);
}
);
# Or construct directly:
use PAGI::FastAPI::Response::Redirect;
$app->get('/old-path',
handler => async sub ($c) {
return PAGI::FastAPI::Response::Redirect->new(
location => '/new-path',
status => 307,
);
}
);
DESCRIPTION
A thin subclass of PAGI::FastAPI::Response that sets the Location header and an appropriate redirect status code (defaulting to 302 Found via the base class's status default, pass status explicitly for 301, 303, 307, or 308 as your use case requires).
METHODS
redirect_to($location, %opts)
Exported on request. Convenience function equivalent to PAGI::FastAPI::Response::Redirect->new(location => $location, status => 302, %opts), so you don't have to remember to pass status for the common case. Pass status in %opts to override (e.g. 301, 303, 307, 308).
new(%options)
location- (Required) The target URL or path for theLocationheader.status- (Optional) HTTP status code. Inherited from PAGI::FastAPI::Response, whose own default is200, for an actual redirect, passstatusexplicitly (or useredirect_to()above, which defaults it to302for you).body- (Optional) Response body. Defaults to''(empty), which is correct for most redirects.
SEE ALSO
PAGI::FastAPI::Response, PAGI::FastAPI::Response::HTML, PAGI::FastAPI::Response::SSE
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::Redirect
You can also look for information at:
BUG Report
Search MetaCPAN
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).