From: Art on
Hello -

I have a macro that is used to send http response. There is a
key :type that can be :html or :text and based on that it is sent a
text or html header as a response. Here it is:

(defmacro with-response ((request &key (type :html)) &body body)
(let ((stream (gensym "STREAM")))
`(let ((,stream (http-request-stream request)))
(flet ((echo (string) (send-string ,stream string)))
,(ecase type
(:html `(send-html-response ,stream ))
(:text `(send-text-response ,stream)))
(progn ,@body)
(force-output ,stream)))))

I want to make two macros based on the with-response macro, with-html-
response and with-text-response. The idea is like this:

(defmacro with-html-response ((request) &body body)
(with-response (request :type :html) body))

(defmacro with-text-response ((request) &body body)
(with-response (request :type :text) body))


How to write the with-html-response and with-text-response macros
correctly, that they "reuse" the with-response macro?


Thanks,
Art
From: Frode V. Fjeld on
Art <artobrezan(a)yahoo.com> writes:

> (defmacro with-text-response ((request) &body body)
> (with-response (request :type :text) body))
>
> How to write the with-html-response and with-text-response macros
> correctly, that they "reuse" the with-response macro?

I would guess like so?

(defmacro with-text-response ((request) &body body)
`(with-response (,request :type :text) ,@body))


--
Frode V. Fjeld
From: Art on
Yes, thank you very much! It works now. :)

> I would guess like so?
>
>  (defmacro with-text-response ((request) &body body)
>    `(with-response (,request :type :text) ,@body))