Hello,

I'm trying to write a simple module for the haskell web server (hws- cgi).

And I would like to write a simple module that maintains some kind of state for a session.

But I'm I write I cannot do this in pure Haskell ? Without adopting the sources of the Haskell web server ?

I'll examplify to make it more concrete :

The requestHandler function a module has to implement has this signature.

requestHandler :: ServerState -> ServerRequest  -> IO (Maybe Response)

Let 's assume I have this implementation

requestHandler st _ = return $ Just  $ mkRequest
    where mkRequest =
              okResponse (serverConfig st) mkBody hs True
          mkBody = HereItIs " This is a test"
          hs = mkHeaders [contentTypeHeader "text/html"]

And I would like the response to include, for example, a number indicating the number of calls that has been handled by the module.

I would concider using an Mvar but I can't "remember" the mvar between requests.

Am I right to assume that the interface of the requestHandler method has to be adapted ? Or that serverstate has to be adopted so that it can act as a datastore ?

kind regards,

Pieter
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to