-
Notifications
You must be signed in to change notification settings - Fork 258
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
return uri to redirect to #418
Comments
If you visit # plumber.R
#' @get /redirected
function(req, res) {
"worked!"
}
#' @get /
#' @html
function(req, res) {
res$status <- 303 # redirect
res$setHeader("Location", "./redirected")
"<html>
<head>
<meta http-equiv=\"Refresh\" content=\"0; url=./redirected\" />
</head>
<body>
<p>Please follow <a href=\"http://www.example.com/\">this link</a>.</p>
</body>
</html>"
} Server plumber::plumb("plumber.R")$run(port = 12345) Testing # bash
curl http://127.0.0.1:12345/
# <html>
# <head>
# <meta http-equiv="Refresh" content="0; url=./redirected" />
# </head>
# <body>
# <p>Please follow <a href="http://www.example.com/">this link</a>.</p>
# </body>
# </html>
# Follow redirects using curl
curl http://127.0.0.1:12345/ -L
# ["worked!"] |
Thanks! I’ll try this out. |
how would it work in this case that I want to redirect to a site outside of my server?
|
Yup. That should work! The header is for applications like curl. The |
ah the swagger returns an error, but the app redirects correctly. |
Ah. The response type is set to |
Closing for now. I'll make an issue for getting content type / swagger info from serializers |
how do i build a return from a get so based on the input a new url is created and as a result a redirect to the uri is invoked? i can return the uri as a string via
@html
.The text was updated successfully, but these errors were encountered: