[web-devel] Yesod: Dynamic subdomains
michael at snoyman.com
Sat Aug 27 20:09:12 CEST 2011
On Fri, Aug 26, 2011 at 4:09 PM, "Timo B. Hübel" <t.h at gmx.info> wrote:
> 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?
I've put up a cookbook recipe for domain-based routing. 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 and then lookup the "Host"
header in requestHeaders.
Let's direct any follow-up discussion to the Yesod mailing list (CCed).
More information about the web-devel