Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable sessions in Yesod for a specific set of urls or a subsite?

I want to disable sessions for headless API endpoints, but I have to keep them turned on because this service also handles user logins.

However makeSessionBackend doesn't have access to Handler stuff or even current URI, like isAuthorizedSource does.

It appears to me that I should lift Client Session Backend code and sprinkle it with wrappers until the moment I can get at least textual path from that WAI Request.

Isn't there a better way to tell any bakend to ignore some routes like StaticR?

like image 745
wiz Avatar asked Jan 31 '15 17:01

wiz


1 Answers

All of your points can be modified by overriding the makeSessionBackend method in the Yesod typeclass. Something like

instance Yesod App where
    makeSessionBackend _ = fmap Just $ defaultClientSessionBackend expireTime filepath
      where expireTime = 24 * 60
like image 152
sigrlami Avatar answered Nov 18 '22 05:11

sigrlami