| Copyright | (c) digitally induced GmbH 2020 |
|---|---|
| Safe Haskell | None |
| Language | GHC2021 |
IHP.Controller.Redirect
Description
Synopsis
- redirectTo :: (?request :: Request, HasPath action) => action -> IO ()
- redirectToPath :: (?request :: Request) => Text -> IO ()
- redirectToUrl :: Text -> IO ()
- redirectToSeeOther :: (?request :: Request, HasPath action) => action -> IO ()
- redirectToPathSeeOther :: (?request :: Request) => Text -> IO ()
- redirectToUrlSeeOther :: Text -> IO ()
- redirectBack :: (?request :: Request) => IO ()
- redirectBackWithFallback :: (?request :: Request) => Text -> IO ()
Documentation
redirectTo :: (?request :: Request, HasPath action) => action -> IO () Source #
Redirects to an action
Example:
redirectTo ShowProjectAction { projectId = project.id }Use redirectToPath if you want to redirect to a non-action url.
redirectToPath :: (?request :: Request) => Text -> IO () Source #
Redirects to a path (given as a string)
Example:
redirectToPath "/blog/wp-login.php"
Use redirectTo if you want to redirect to a controller action.
redirectToUrl :: Text -> IO () Source #
Redirects to a url (given as a string)
Example:
redirectToUrl "https://example.com/hello-world.html"
Use redirectToPath if you want to redirect to a relative path like /hello-world.html
redirectToSeeOther :: (?request :: Request, HasPath action) => action -> IO () Source #
Redirects to an action using HTTP 303 See Other
Forces the follow-up request to be a GET (useful after POST/DELETE).
redirectToPathSeeOther :: (?request :: Request) => Text -> IO () Source #
Redirects to a path using HTTP 303 See Other
Forces the follow-up request to be a GET (useful after POST/DELETE).
redirectToUrlSeeOther :: Text -> IO () Source #
Redirects to a url using HTTP 303 See Other
Forces the follow-up request to be a GET (useful after POST/DELETE).
redirectBack :: (?request :: Request) => IO () Source #
Redirects back to the last page
Uses the Referer header to do a redirect to page that got you here.
In case the Referer header is not set this function will redirect to /. Use redirectBackWithFallback when you want
to specify a custom fallback path.
Example:
action LikeAction { postId } = do
post <- fetch postId
post
|> incrementField #likesCount
|> updateRecord
redirectBackredirectBackWithFallback :: (?request :: Request) => Text -> IO () Source #
Redirects back to the last page or the given fallback path in case the Referer header is missing
If you don't care about the missing-Referer-header case, use redirectBack.
Example:
action LikeAction { postId } = do
post <- fetch postId
post
|> incrementField #likesCount
|> updateRecord
redirectBackWithFallback (pathTo ShowPostAction { postId = post.id })