I agree that WAI is well optimized for the common use case, and that this particular use case may call for a change in Yesod rather than WAI. However, not being able to store arbitrary data does limit what can be achieved in WAI. <div>

In Ruby there things (like authentication) that are being done in Rack that would be difficult to achieve in an extensible way without that capability.</div><div>WAI may not seem like the correct layer for those kinds of features. However, in an environment like Ruby where there *every* web framework uses Rack, there is a lot of advantage that can be gained by pushing core features down there.</div>

<div><br><div class="gmail_quote">On Sat, Aug 27, 2011 at 12:10 PM, Michael Snoyman <span dir="ltr">&lt;<a href="mailto:michael@snoyman.com">michael@snoyman.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

The stylesheet: Pandoc compiled without -fhighlighting (as we both<br>
knew would happen eventually ;)). I&#39;m recompiling and uploading a new<br>
copy now.<br>
<br>
I don&#39;t really think this has anything to do with WAI. Firstly, I was<br>
mistaken in using the Host request header, WAI already provides a<br>
serverName record in the Request datatype, I&#39;d simply forgotten about<br>
it. The routing issue is that Yesod only pays attention to the path<br>
info for routing, so we&#39;re &quot;hacking&quot; WAI to expose extra information<br>
in that record that wouldn&#39;t normally be there. I think the real<br>
question is if Yesod needs to be modified to allow routing on<br>
something else, but I think that:<br>
<br>
1. We&#39;ve optimized for the common case, and any deviation from what<br>
we&#39;ve done will make normal usage of Yesod much more difficult.<br>
2. Even though this is a hack, it&#39;s not a particularly bad one, and<br>
all normal Yesod features like type-safe URLs and declarative routing<br>
still work without a hitch.<br>
<font color="#888888"><br>
Michael<br>
</font><div><div></div><div class="h5"><br>
On Sat, Aug 27, 2011 at 9:56 PM, Greg Weber &lt;<a href="mailto:greg@gregweber.info">greg@gregweber.info</a>&gt; wrote:<br>
&gt; Great example! Inspired me to post a recipe for re-directing from www to the<br>
&gt; main domain: <a href="http://www.yesodweb.com/show/topic/536" target="_blank">http://www.yesodweb.com/show/topic/536</a><br>
&gt; Did the syntax high-lighting stylesheet disappear?<br>
&gt;<br>
&gt; The domain-based routing does make me wonder though- in Rack the data<br>
&gt; structure is a hash instead of a record and I could place the sub-domain<br>
&gt; somewhere in the hash. Having a reliable record is much nicer than a hash.<br>
&gt; However, this shows a use-case where we want to save off extra data at the<br>
&gt; WAI level, but there is no way to do so. It seems like WAI should be<br>
&gt; modified in some way to properly accommodate this use case. The first thing<br>
&gt; that comes to my mind is having an extra parameter in the request record<br>
&gt; that is a Map expressly for the purpose of storing data for later use. What<br>
&gt; do you think?<br>
&gt; Greg Weber<br>
&gt;<br>
&gt; On Sat, Aug 27, 2011 at 11:09 AM, Michael Snoyman &lt;<a href="mailto:michael@snoyman.com">michael@snoyman.com</a>&gt;<br>
&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt; On Fri, Aug 26, 2011 at 4:09 PM, &quot;Timo B. Hübel&quot; &lt;<a href="mailto:t.h@gmx.info">t.h@gmx.info</a>&gt; wrote:<br>
&gt;&gt; &gt; Hi,<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; I am building a Yesod web app which should support dynamic subdomains.<br>
&gt;&gt; &gt; I.e. a user registers as &quot;foobar&quot; on <a href="http://www.example.com" target="_blank">http://www.example.com</a> and can<br>
&gt;&gt; &gt; afterwards access her content via <a href="http://foobar.example.com" target="_blank">http://foobar.example.com</a><br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; Is this possible at all? I am wondering, because the server name is<br>
&gt;&gt; &gt; somehow hard coded in Settings.hs as approot.<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; If it is possible: How do I access the domain name in a handler<br>
&gt;&gt; &gt; function?<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; Thanks!<br>
&gt;&gt; &gt; Timo<br>
&gt;&gt;<br>
&gt;&gt; Hi Timo,<br>
&gt;&gt;<br>
&gt;&gt; I&#39;ve put up a cookbook recipe for domain-based routing[1]. It doesn&#39;t<br>
&gt;&gt; require checking domain names in the handler function at all, but<br>
&gt;&gt; instead uses the normal routing mechanism in Yesod. As a direct answer<br>
&gt;&gt; to your question, to get access to the domain name, you&#39;ll want to get<br>
&gt;&gt; the WAI request value via waiRequest[2] and then lookup the &quot;Host&quot;<br>
&gt;&gt; header in requestHeaders[3].<br>
&gt;&gt;<br>
&gt;&gt; Let&#39;s direct any follow-up discussion to the Yesod mailing list (CCed).<br>
&gt;&gt;<br>
&gt;&gt; Michael<br>
&gt;&gt;<br>
&gt;&gt; [1] <a href="http://www.yesodweb.com/wiki/Domain-based%20routing" target="_blank">http://www.yesodweb.com/wiki/Domain-based%20routing</a><br>
&gt;&gt; [2]<br>
&gt;&gt; <a href="http://hackage.haskell.org/packages/archive/yesod-core/0.8.3.2/doc/html/Yesod-Handler.html#v:waiRequest" target="_blank">http://hackage.haskell.org/packages/archive/yesod-core/0.8.3.2/doc/html/Yesod-Handler.html#v:waiRequest</a><br>


&gt;&gt; [3]<br>
&gt;&gt; <a href="http://hackage.haskell.org/packages/archive/wai/0.4.1/doc/html/Network-Wai.html#v:requestHeaders" target="_blank">http://hackage.haskell.org/packages/archive/wai/0.4.1/doc/html/Network-Wai.html#v:requestHeaders</a><br>


&gt;<br>
&gt;<br>
</div></div></blockquote></div><br></div>