Created
March 2, 2017 01:17
-
-
Save lsmag/6423b017e94750bc475468038c792e47 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
loginRequired = requireUser auth handleRedirect | |
where | |
-- this is the cleanest way (afaik) to write it | |
handleRedirect = withRequest (redirect . append "/login?to=" . rqURI) | |
-- that handleRedirect can be rewritten in a more imperative way: | |
handleRedirect = withRequest (\rq -> redirect (append "login?to=" (rqURI rq))) | |
-- or | |
handleRedirect = withRequest (\rq -> redirect . append "login?to=" . rqURI $ rq) | |
-- or? | |
handleRedirect = withRequest | |
(\rq -> | |
let uri = rqURI rq | |
loginRoute = append "login?to=" uri | |
in redirect loginRoute) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment