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"><<a href="mailto:michael@snoyman.com">michael@snoyman.com</a>></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'm recompiling and uploading a new<br>
copy now.<br>
<br>
I don'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'd simply forgotten about<br>
it. The routing issue is that Yesod only pays attention to the path<br>
info for routing, so we're "hacking" WAI to expose extra information<br>
in that record that wouldn'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've optimized for the common case, and any deviation from what<br>
we've done will make normal usage of Yesod much more difficult.<br>
2. Even though this is a hack, it'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 <<a href="mailto:greg@gregweber.info">greg@gregweber.info</a>> wrote:<br>
> Great example! Inspired me to post a recipe for re-directing from www to the<br>
> main domain: <a href="http://www.yesodweb.com/show/topic/536" target="_blank">http://www.yesodweb.com/show/topic/536</a><br>
> Did the syntax high-lighting stylesheet disappear?<br>
><br>
> The domain-based routing does make me wonder though- in Rack the data<br>
> structure is a hash instead of a record and I could place the sub-domain<br>
> somewhere in the hash. Having a reliable record is much nicer than a hash.<br>
> However, this shows a use-case where we want to save off extra data at the<br>
> WAI level, but there is no way to do so. It seems like WAI should be<br>
> modified in some way to properly accommodate this use case. The first thing<br>
> that comes to my mind is having an extra parameter in the request record<br>
> that is a Map expressly for the purpose of storing data for later use. What<br>
> do you think?<br>
> Greg Weber<br>
><br>
> On Sat, Aug 27, 2011 at 11:09 AM, Michael Snoyman <<a href="mailto:michael@snoyman.com">michael@snoyman.com</a>><br>
> wrote:<br>
>><br>
>> On Fri, Aug 26, 2011 at 4:09 PM, "Timo B. Hübel" <<a href="mailto:t.h@gmx.info">t.h@gmx.info</a>> wrote:<br>
>> > Hi,<br>
>> ><br>
>> > I am building a Yesod web app which should support dynamic subdomains.<br>
>> > I.e. a user registers as "foobar" on <a href="http://www.example.com" target="_blank">http://www.example.com</a> and can<br>
>> > afterwards access her content via <a href="http://foobar.example.com" target="_blank">http://foobar.example.com</a><br>
>> ><br>
>> > Is this possible at all? I am wondering, because the server name is<br>
>> > somehow hard coded in Settings.hs as approot.<br>
>> ><br>
>> > If it is possible: How do I access the domain name in a handler<br>
>> > function?<br>
>> ><br>
>> > Thanks!<br>
>> > Timo<br>
>><br>
>> Hi Timo,<br>
>><br>
>> I've put up a cookbook recipe for domain-based routing[1]. It doesn't<br>
>> require checking domain names in the handler function at all, but<br>
>> instead uses the normal routing mechanism in Yesod. As a direct answer<br>
>> to your question, to get access to the domain name, you'll want to get<br>
>> the WAI request value via waiRequest[2] and then lookup the "Host"<br>
>> header in requestHeaders[3].<br>
>><br>
>> Let's direct any follow-up discussion to the Yesod mailing list (CCed).<br>
>><br>
>> Michael<br>
>><br>
>> [1] <a href="http://www.yesodweb.com/wiki/Domain-based%20routing" target="_blank">http://www.yesodweb.com/wiki/Domain-based%20routing</a><br>
>> [2]<br>
>> <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>
>> [3]<br>
>> <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>
><br>
><br>
</div></div></blockquote></div><br></div>