R/redirect.R

Defines functions redirect

Documented in redirect

#' Create a redirect response
#'
#' Create a response to redirect to a destination.
#' @param dest A destination path.
#' @param status The status code (usually \code{301} or \code{302}).
#' @export
#' @examples
#' servr::redirect('https://www.r-project.org')
redirect = function(dest, status = 301L) {
  list(status = status, body = '', headers = list('Location' = dest))
}

Try the servr package in your browser

Any scripts or data that you put into this service are public.

servr documentation built on Oct. 5, 2024, 1:06 a.m.