servlet.scm
(module servlet mzscheme
  (provide servlet)
   
  (require (lib "servlet.ss" "web-server")
           (lib "xml.ss" "xml")
           
           "cookie.scm"
           "binding.scm"
           "response.scm"
           "request.scm"
           "default.scm")
  
  (define-syntax servlet 
    (syntax-rules ()
      [(servlet body ...)
       (lambda (initial-request)
         (with-defaults
             (parameterize ([current-request        initial-request]
                            [current-cookies        (request-cookies initial-request)]
                            [current-output-cookies '()]
                            [current-bindings       (request-bindings initial-request)])
               ; (display "--\n")
               ; (display (format "in> cookies: ~a\n" (current-cookies)))
               ; (display (format "in> bindings: ~a\n" (current-bindings)))
               (let ([document 
                      (xexpr->string 
                       (begin body ...))])
                 
                 ;(output-cookie (make-cookie "time" (number->string (current-seconds)) #:max-age 3600))
                 ;(output-cookie (make-cookie "id" "soegaard"))
                 ;(display (format "out> cookies: ~a\n" (current-output-cookies)))
                 
                 ;(save-persistent-parameters)
                 (make-response document)))))]))
  
  )