[racket-dev] [racket] Explicitly rerouting web-server requests to filesystem server

From: Jay McCarthy (jay.mccarthy at gmail.com)
Date: Wed May 8 12:52:58 EDT 2013

I have just pushed this change.

On Tue, May 7, 2013 at 8:53 PM, Matthew Butterick
<mb.list.acct at gmail.com> wrote:
> Thanks for the help Jay. That worked.
>
> BTW I'm enjoying doing web programming with Racket. A small suggestion, if
> you keep a pile of them.
>
> It would be great to have a #:command-char keyword option in the
> include-template function, for two reasons.
>
> First, @-expressions are awkward in web templates. @ signs may be rare in
> Racket, but they're common in web pages. True, you can escape them, but if
> you're gluing together code from other sources, it's a layer of policing
> that's prone to error. So it would be convenient to designate another
> character.
>
> (In response to another question I posted on the list, Matthew Flatt made a
> bugfix that allows any unicode glyph as a command-char. So there are now
> zillions of options for command-chars.)
>
> Second, designating the command-char would allow multiple layers of
> evaluation. For instance, suppose I make my web template using scribble/text
> as a preprocessor, and designate ◊ as a delimiter. I designate the template
> fields using a different delimiter, say ∑. (e.g., ∑title, ∑body, ∑comments).
> In the preprocessor stage, these will just be interpreted as text.
>
> But when I use the template, I can do something like this:
>
> (include-template #:command-char ∑ "template.html")
>
> Then ∑title, ∑body, and ∑comments would be interpreted as expressions in the
> current lexical context.
>
>
>
>
>
> On Mon, May 6, 2013 at 5:53 AM, Jay McCarthy <jay.mccarthy at gmail.com> wrote:
>>
>> On Sun, May 5, 2013 at 1:12 AM, Matthew Butterick
>> <mb.list.acct at gmail.com> wrote:
>> > The docs for web-server/dispatch allude to the filesystem server that
>> > lurks
>> > behind the dispatch rules to handle requests that are not handled by
>> > dispatch rules.
>> >
>> > Is there a way to explicitly send a request to the filesystem server?
>> >
>> > For instance, I have a dispatch route that checks if the requested file
>> > exists, and if not, generates it immediately and saves it to disk.
>> > However,
>> > at that point, I'd prefer to take the original request and pass it to
>> > the
>> > filesystem server.
>>
>> The default dispatcher chain puts the filesystem server directly after
>> the servlet handler and then the "file not found" handler is after
>> that. If you ever want to have a dispatcher skip to the next one, you
>> can call (next-dispatcher), even if you've done work like creating a
>> file. Alternatively, you could explicitly call the file server by
>> embedding it into your servlet, but I don't recommend that.
>>
>> Jay
>>
>> --
>> Jay McCarthy <jay at cs.byu.edu>
>> Assistant Professor / Brigham Young University
>> http://faculty.cs.byu.edu/~jay
>>
>> "The glory of God is Intelligence" - D&C 93
>
>



-- 
Jay McCarthy <jay at cs.byu.edu>
Assistant Professor / Brigham Young University
http://faculty.cs.byu.edu/~jay

"The glory of God is Intelligence" - D&C 93


Posted on the dev mailing list.