Hello All,
Basically I'm practice the session snaplet and got one question.
I define the App as:
data App = App
{ _heist :: Snaplet (Heist App)
, _startTime :: UTCTime
, _appSession :: Snaplet SessionManager
}
and init it as:
app :: SnapletInit App App
app = makeSnaplet "app" "An snaplet example application." Nothing $ do
sTime <- liftIO getCurrentTime
h <- nestSnaplet "heist" heist $ heistInit "resources/templates"
s <- nestSnaplet "session" appSession $ initCookieSessionManager "log/site-key.txt" "myapp-session" (Just 600)
addRoutes routes
return $ App h sTime s
Then in the `index` handler I set a session value:
with appSession $ withSession appSession $ setInSession "user_age" "32"
Afterwards in the `echo` handler I like to get the value:
sv <- with appSession $ getFromSession "user_age"
It all works well.
And my question is in the `index` handler when I put something into session, I have to do:
`with appSession $ withSession appSession $...`
The appSession is used twice and everytime I'd like to play session operation I need `with appSession`.
I think I'm able to make couple of util functions to be a little clear.
But I still wondering whether I'm using the session snaplet incorrectly?
In other words, do we have any type class like `hasHeist` or `HasMongoDBState` to make it simpler?
Thanks a lot!
-Simon