
On Fri, Aug 26, 2011 at 4:09 PM, "Timo B. Hübel"
Hi,
I am building a Yesod web app which should support dynamic subdomains. I.e. a user registers as "foobar" on http://www.example.com and can afterwards access her content via http://foobar.example.com
Is this possible at all? I am wondering, because the server name is somehow hard coded in Settings.hs as approot.
If it is possible: How do I access the domain name in a handler function?
Thanks! Timo
Hi Timo, I've put up a cookbook recipe for domain-based routing[1]. It doesn't require checking domain names in the handler function at all, but instead uses the normal routing mechanism in Yesod. As a direct answer to your question, to get access to the domain name, you'll want to get the WAI request value via waiRequest[2] and then lookup the "Host" header in requestHeaders[3]. Let's direct any follow-up discussion to the Yesod mailing list (CCed). Michael [1] http://www.yesodweb.com/wiki/Domain-based%20routing [2] http://hackage.haskell.org/packages/archive/yesod-core/0.8.3.2/doc/html/Yeso... [3] http://hackage.haskell.org/packages/archive/wai/0.4.1/doc/html/Network-Wai.h...