You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Guide/controller.markdown
+21Lines changed: 21 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -350,6 +350,13 @@ When you need to pass a custom query parameter, you cannot use the [`redirectTo`
350
350
351
351
The redirect will use HTTP status code `302`. The [`baseUrl`](https://ihp.digitallyinduced.com/api-docs/IHP-FrameworkConfig.html#t:FrameworkConfig) in `Config/Config.hs` will be used. In development mode, the [`baseUrl`](https://ihp.digitallyinduced.com/api-docs/IHP-FrameworkConfig.html#t:FrameworkConfig) might not be specified in `Config/Config.hs`. Then it will be set to localhost by default.
352
352
353
+
If you need to force the follow-up request to be a `GET` (e.g. after a `POST` or `DELETE`), use [`redirectToSeeOther`](https://ihp.digitallyinduced.com/api-docs/IHP-Controller-Redirect.html#v:redirectToSeeOther) to send a 303 See Other:
354
+
355
+
```haskell
356
+
action ExampleAction=do
357
+
redirectToSeeOther ShowPostAction { postId =... }
358
+
```
359
+
353
360
### Redirect to a Path
354
361
355
362
Use [`redirectToPath`](https://ihp.digitallyinduced.com/api-docs/IHP-Controller-Redirect.html#v:redirectToPath) when you want to redirect to a path on the same domain:
Use [`redirectToPathSeeOther`](https://ihp.digitallyinduced.com/api-docs/IHP-Controller-Redirect.html#v:redirectToPathSeeOther) to send a 303 redirect to a path:
377
+
378
+
```haskell
379
+
action ExampleAction=do
380
+
redirectToPathSeeOther "/blog/wp-login.php"
381
+
```
382
+
369
383
### Redirect to a URL
370
384
371
385
Use [`redirectToUrl`](https://ihp.digitallyinduced.com/api-docs/IHP-Controller-Redirect.html#v:redirectToUrl) to redirect to some external URL:
Use [`redirectToUrlSeeOther`](https://ihp.digitallyinduced.com/api-docs/IHP-Controller-Redirect.html#v:redirectToUrlSeeOther) to send a 303 redirect to some external URL:
When calling a function to send the response, IHP will stop executing the action. Internally this is implemented by throwing and catching a [`ResponseException`](https://ihp.digitallyinduced.com/api-docs/src/IHP.ControllerSupport.html#ResponseException). Any code after e.g. a `render SomeView { .. }` call will not be called. This also applies to all redirect helpers.
0 commit comments