chicken-users
[Top][All Lists]
Advanced

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

Re: [Chicken-users] how to get cookies working for pages defined via def


From: felix winkelmann
Subject: Re: [Chicken-users] how to get cookies working for pages defined via define-http-resource
Date: Sun, 29 May 2005 11:45:40 +0200

Thanks, I've applied the patch (and added machinery to pass
the result of (current-response-code) as well).


cheers,
felix

On 5/28/05, Michele Simionato <address@hidden> wrote:
> ``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) ) ) ) ) ) ) ) ) 
> ) )
> 
> 
> _______________________________________________
> Chicken-users mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/chicken-users
>




reply via email to

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