chicken-users
[Top][All Lists]
Advanced

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

[Chicken-users] how to get cookies working for pages defined via define-


From: Michele Simionato
Subject: [Chicken-users] how to get cookies working for pages defined via define-http-resource
Date: Sat, 28 May 2005 02:18:02 -0400

``define-http-resource`` was missing a headers argument; so I patched
it adding ``headers: (current-response-headers)``. Here is the code:

(define-macro (define-http-resource head . body)
  (let ([url (->string (car head))]
        [rargs (map (lambda (arg)
                      (cond [(and (list? arg) (= 2 (length arg))) 
                             (cons (->string (car arg))
                                   (cadr arg)) ]
                            [(pair? arg) (syntax-error 'define-http-resource 
"invalid argument" arg)]
                            [else (cons (->string arg) #f)] ) )
                    (cdr head) ) ] 
        [req (gensym)]
        [ret (gensym)]
        [args (gensym)] )
    `(http:add-resource
      ,url
      (lambda (,req ,args)
      (parameterize ((current-urlencoded-arguments ,args)
                     (current-request ,req))
        (call/cc
         (lambda (,ret)
           (let ([respond (http-resource:responder ,req ,ret)])
             (handle-exceptions exn
                 (parameterize
                   ([http:error-response-handler
(http-resource:error-handler exn)])
                   (http:write-error-response 500 "Internal Server Error") )
               (respond
                (let ,(map (lambda (arg)
                             `(,(string->symbol (car arg)) (alist-ref ,(car 
arg) ,args
string-ci=? ,(cdr arg))) )
                           rargs)
                  ,@body) headers: (current-response-headers) ) ) ) ) ) ) ) ) ) 
)




reply via email to

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