
How could I use haxr (http://www.haskell.org/haskellwiki/HaXR) to build a stateful server? It should listen on some port, and fork threads (inside Haskell land) to handle incoming calls. Any of the Haskell web frameworks can do this? I guess this is the same question as: http://www.haskell.org/pipermail/haskell-cafe/2009-December/071185.html Thanks - J.W.

It seems like the issue is that HaXR uses CGI, whereas you want to tie
it in with a web server, correct? There's a deprecated package[1] to
allow CGI apps to be run on any WAI handler (such as Warp). If you'd
be interested in using the code, I could help bring it up to snuff
with the most recent WAI, especially if you'd be interested in taking
over maintenance of it.
[1] http://hackage.haskell.org/package/wai-frontend-monadcgi
On Thu, Jan 5, 2012 at 5:40 PM, Johannes Waldmann
How could I use haxr (http://www.haskell.org/haskellwiki/HaXR) to build a stateful server?
It should listen on some port, and fork threads (inside Haskell land) to handle incoming calls. Any of the Haskell web frameworks can do this?
I guess this is the same question as: http://www.haskell.org/pipermail/haskell-cafe/2009-December/071185.html
Thanks - J.W.
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Michael Snoyman
It seems like the issue is that HaXR uses CGI, whereas you want to tie it in with a web server, correct?
Yes.
There's a deprecated package[1] to allow CGI apps to be run on any WAI handler (such as Warp).
why deprecated? what's the problem with that package? J.W.

On Thu, Jan 5, 2012 at 6:03 PM, Johannes Waldmann
Michael Snoyman
writes: It seems like the issue is that HaXR uses CGI, whereas you want to tie it in with a web server, correct?
Yes.
There's a deprecated package[1] to allow CGI apps to be run on any WAI handler (such as Warp).
why deprecated? what's the problem with that package?
J.W.
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Nothing wrong with it as far as I know, I just haven't updated it in a while. There might be some issues implementing streaming request bodies with WAI 0.4 (enumerator-based), but WAI 1.0 (conduit-based) should handle it just fine. Michael

On Thu, Jan 5, 2012 at 9:40 AM, Johannes Waldmann
How could I use haxr (http://www.haskell.org/haskellwiki/HaXR) to build a stateful server?
It should listen on some port, and fork threads (inside Haskell land) to handle incoming calls. Any of the Haskell web frameworks can do this?
I guess this is the same question as: http://www.haskell.org/pipermail/haskell-cafe/2009-December/071185.html
Pretty much any of the Haskell web frameworks listen on a port, accept HTTP requests and fork a new GHC thread into a handler. I'm more familiar with the Happstack/Snap approach to writing handlers (although the Snap approach is evolving away from Happstack), and a lot of people have good luck with Yesod. Happstack crash course: http://happstack.com/docs/crashcourse/index.html Snap quickstart: http://snapframework.com/docs/quickstart Installing and starting yesod in five minutes: http://www.yesodweb.com/page/five-minutes In particular, I know that the folks working on yesod have spent a lot of time on documentation. Antoine
Thanks - J.W.
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

On Thu, Jan 5, 2012 at 10:40 AM, Johannes Waldmann
How could I use haxr (http://www.haskell.org/haskellwiki/HaXR) to build a stateful server?
It should listen on some port, and fork threads (inside Haskell land) to handle incoming calls. Any of the Haskell web frameworks can do this?
I use HaXR in conjunction with Snap. It basically boils down to using Network.XmlRpc.Server (handleCall, methods) in conjunction with Snap's getRequestBody and writeLBS. The good news is you don't need to worry about forking your own threads, the web server handles that. To make calls stateful, you just stash away a reference in the handler you give Snap (or whatever web server you use). Anthony

On Thu, Jan 5, 2012 at 5:40 PM, Johannes Waldmann
How could I use haxr (http://www.haskell.org/haskellwiki/HaXR) to build a stateful server?
It should listen on some port, and fork threads (inside Haskell land) to handle incoming calls. Any of the Haskell web frameworks can do this?
I guess this is the same question as: http://www.haskell.org/pipermail/haskell-cafe/2009-December/071185.html
Just an FYI for everyone. Johannes and I discussed this a bit off-list, and decided that the wai-frontend-monadcgi package would be a good fit for this use case. I deprecated this package because MonadCGI requires lazy I/O for the request body, and enumerator-based WAI 0.4 cannot provide a lazy request body[1]. However, WAI 1.0 will be based on conduits, which does allow lazy I/O. I've added the wai-frontend-monadcgi to the wai repository[2] and will release it when the rest of WAI 1.0 is released. Michael [1] Without resorting to hacks like forking a separate thread and piping data through a Chan. [2] https://github.com/yesodweb/wai
participants (4)
-
Anthony Cowley
-
Antoine Latter
-
Johannes Waldmann
-
Michael Snoyman