chicken-users
[Top][All Lists]
Advanced

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

Re: [Chicken-users] dynamic web resources?


From: felix winkelmann
Subject: Re: [Chicken-users] dynamic web resources?
Date: Mon, 16 Oct 2006 11:17:18 +0200

On 10/15/06, Kon Lovett <address@hidden> wrote:

This might help:

http://lists.gnu.org/archive/html/chicken-hackers/2006-10/msg00007.html

In fact, adding this is simple enough like this (mind-bogglingly naive
example follows):

(http:fallback-handler
(let ((old (http:fallback-handler)))
  (lambda (req)
    (let ((url (http:request-url req)))
      (match (string-match "/add/(.*)" url)
         ((_ text)
          (let ((result (->string (apply + (map string->number (string-split
text "/"))))))
            (write-response-header req)
            (printf "Content-Length: ~A\r\n\r\n~a" (string-length result) 
result)))
         (_ (old req)))))))

This of course screams out for a better interface, but the implementation
is relatively straightforward (for example keeping "dynamic" urls/handlers in
a separate hash-table).


cheers,
felix


--
http://galinha.ucpel.tche.br:8081/blog/blog.ssp




reply via email to

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