Skip to content

Commit

Permalink
Enhance with-response-body macro a bit.
Browse files Browse the repository at this point in the history
  • Loading branch information
gigamonkey committed Jan 5, 2012
1 parent 86ae677 commit 7598c86
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions api.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,16 @@ restarted with START-ACCEPTOR."
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Public API

(defmacro with-response-body ((stream request) &body body)
`(let ((,stream (send-headers ,request)))
,@body))
(defmacro with-response-body ((stream request &rest headers &key &allow-other-keys) &body body)
(once-only (request)
`(progn
;; When headers is NIL SBCL whines about unreachable code if we
;; generate the LOOP
,@(when headers
`((loop for (name value) on (list ,@headers) by #'cddr do
(setf (response-header name ,request) value))))
(let ((,stream (send-headers ,request))) ,@body)
t)))

(defun response-header (name request)
"Returns the current value of the outgoing http header named NAME.
Expand Down

0 comments on commit 7598c86

Please sign in to comment.