web/response: re-arrange code, esp. interaction stuff

This commit is contained in:
Helmut Merz 2024-07-26 16:16:53 +02:00
parent 7c4b22d5f8
commit 0d8fd57920

View file

@ -11,6 +11,20 @@
(in-package :scopes/web/response)
;;;; server interaction - receive response message from action processing chain
(defclass interaction ()
((messages :accessor messages :initform nil)))
(defmethod print-object ((ia interaction) s)
(format s "<interaction ~s>" (messages ia)))
(defmethod core:send ((ia interaction) msg)
(log:debug "receiving ~s" msg)
(push msg (messages ia)))
;;;; response definitions
(defvar *html-response-class* nil)
(defclass response ()
@ -26,18 +40,6 @@
(defclass json-response (response)
((ctype :initform "application/json")))
;;;; server interaction - receive response message from action processing chain
(defclass interaction ()
((messages :accessor messages :initform nil)))
(defmethod print-object ((ia interaction) s)
(format s "<interaction ~s>" (messages ia)))
(defmethod core:send ((ia interaction) msg)
(log:debug "receiving ~s" msg)
(push msg (messages ia)))
;;;; html response
(defclass html-response (response)
@ -75,8 +77,6 @@
(dolist (msg (messages iact))
(funcall writer (render-content resp msg)))
(funcall writer nil :close t)))))
; (content (mapcar #'(lambda (m) (render-content resp m)) (messages iact))))
;(list rcode headers content)))
(defun render-not-found(resp)
(list 404 '(:content-type "text/plain") '("Not found")))