chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Chicken-users] Spiffy Question: handle-not-found


From: Taylor Venable
Subject: [Chicken-users] Spiffy Question: handle-not-found
Date: Sun, 14 Feb 2010 11:39:18 -0500

Hi, I'm using Spiffy and setting handle-not-found in an attempt to use
Spiffy like a generic URL-based dispatcher.  For example, when the user
requests /foo/bar I want to send back the result of calling function x,
and when the user requests /asdf/jkl I want to send back the result of
calling function y:

(handle-not-found
  (lambda (path)
    (log-to (debug-log) "REQUEST: ~s" path)
    (cond ((string=? uri "/foo/bar")
           (x))
          ((string=? uri "/asdf/jkl")
           (y))
          (else
           (handle-other)))))

The Spiffy documentation says about the value of handle-not-found: "It
is a procedure of one argument, the path (a string) that was requested."
However, it seems that the actual argument is the path, up until the
first component which was not found. If root-path does not exist, path
is always "/". If root-path does exist, but neither "foo" nor "asdf"
exist within it, then path is always "/foo" or "/asdf". That's what it
seems to be, anyway; is that the correct behaviour? It seems to be
slightly different from what the documentation says, since it is not
necessarily the requested path.

In the meantime I've been using this code as a workaround to get what I
want regardless of the existence of files in the path:

(string-join (cdr (uri-path (request-uri (current-request)))) "/" 'prefix)

Thanks for the clarification,

-- 
Taylor Venable
http://metasyntax.net/





reply via email to

[Prev in Thread] Current Thread [Next in Thread]