| 1 |
% Generated by roxygen2: do not edit by hand |
| 2 |
% Please edit documentation in R/server.R |
| 3 |
\name{handler_redirect} |
| 4 |
\alias{handler_redirect} |
| 5 |
\title{Create HTTP Redirect Handler} |
| 6 |
\usage{ |
| 7 |
handler_redirect(path, location, status = 302L, prefix = FALSE) |
| 8 |
} |
| 9 |
\arguments{ |
| 10 |
\item{path}{URI path to match (e.g., "/old-page").} |
| 11 |
|
| 12 |
\item{location}{URL to redirect to. Can be relative (e.g., "/new-page") or |
| 13 |
absolute (e.g., "https://example.com/page").} |
| 14 |
|
| 15 |
\item{status}{HTTP redirect status code. Must be one of: |
| 16 |
\itemize{ |
| 17 |
\item 301 - Moved Permanently |
| 18 |
\item 302 - Found (default) |
| 19 |
\item 303 - See Other |
| 20 |
\item 307 - Temporary Redirect |
| 21 |
\item 308 - Permanent Redirect |
| 22 |
}} |
| 23 |
|
| 24 |
\item{prefix}{[default FALSE] Logical, if TRUE matches path as a prefix.} |
| 25 |
} |
| 26 |
\value{ |
| 27 |
A handler object for use with \code{\link[=http_server]{http_server()}}. |
| 28 |
} |
| 29 |
\description{ |
| 30 |
Creates an HTTP handler that returns a redirect response. |
| 31 |
} |
| 32 |
\examples{ |
| 33 |
# Permanent redirect |
| 34 |
h1 <- handler_redirect("/old", "/new", status = 301L) |
| 35 |
|
| 36 |
# Redirect bare path to trailing slash |
| 37 |
h2 <- handler_redirect("/app", "/app/") |
| 38 |
|
| 39 |
} |