IHP Api Reference
Copyright(c) digitally induced GmbH 2020
Safe HaskellSafe-Inferred

IHP.Controller.Redirect

Description

 
Synopsis

Documentation

redirectTo :: (?context :: ControllerContext, 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 :: (?context :: ControllerContext) => 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 :: (?context :: ControllerContext) => 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

redirectBack :: (?context :: ControllerContext) => 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

    redirectBack

redirectBackWithFallback :: (?context :: ControllerContext) => 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 })