Servant Redirects

How to configure a Servant handler with redirection? I am working in a REST application for navigation, and I would like to respond to POST requests that create resources with redirection to the corresponding paths of the GET resource list. So, for example, POST / foos should be redirected to GET / foos after creating foo. I could not find a clear way to do this in the documentation.

+4
source share
1 answer

There is one simple (but slightly hacked) answer, and a guide for making the first option obsolete (EDIT: and the third, best option, actually).

- , Handler MonadError ServantErr ServantErr - " ", HTTP- , . , - throwError $ err301 { errHeaders = [("Location", "https://haskell.org/")] }. , "" . .

, , / . , , , .

, , . , , , ! . , . , . , , . , PostRedirect, ( , , ), , .

+5

Source: https://habr.com/ru/post/1687629/


All Articles