Is there a library for relative redirects?

4 views
Skip to first unread message

Sönke Hahn

unread,
Jun 28, 2016, 5:35:26 AM6/28/16
to haskell-wai
Hi all,

I'm writing a wai Application where I want one endpoint to redirect to another. Ideally I would be able to use this Application hosted top-level (e.g. on `example.com/`) but also on subpaths (e.g. `example.com/foo`) without changing the code. One approach I have seen (in python projects) is to just have a global configuration variable that has to be set to the path where the application is hosted. This is then used to construct absolute redirects. However I'd like to use relative redirects to get away without that. And wai also nicely allows that (through `pathInfo` and `rawPathInfo`), as long as the routing libraries behave correctly.

Is there a library for these kinds of redirects already?

Cheers,
Sönke

Michael Snoyman

unread,
Jun 28, 2016, 5:49:20 AM6/28/16
to Sönke Hahn, haskell-wai
There's not a library for it, but this is exactly the approach I took in wai-application-static. Unfortunately, I don't think the logic I used there is easily extractable to a general-purpose library.

FWIW, Yesod goes the approach of asking for the path where the app is hosted (in Yesod terms, the approot).

--
You received this message because you are subscribed to the Google Groups "haskell-wai" group.
To unsubscribe from this group and stop receiving emails from it, send an email to haskell-wai...@googlegroups.com.
To post to this group, send email to haske...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/haskell-wai/bbef798d-6e9b-4370-b7b3-d38f0a7ac34d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Sönke Hahn

unread,
Jun 28, 2016, 5:53:04 AM6/28/16
to haskell-wai, soenk...@gmail.com, mic...@snoyman.com
Hey Michael,

thanks for the reply.

Maybe I'll whip up a library. I'll report back here if I do.

Cheers,
Sönke
Reply all
Reply to author
Forward
0 new messages