wiz
wiz

Reputation: 500

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?

Upvotes: 6

Views: 124

Answers (1)

sigrlami
sigrlami

Reputation: 1832

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

Upvotes: 2

Related Questions