web/response, work in progress: render cookie data supplied by downstream service
This commit is contained in:
parent
cf7d85af4d
commit
2a4d3af1dd
1 changed files with 17 additions and 2 deletions
|
@ -18,12 +18,16 @@
|
|||
((messages :accessor messages :initform nil)))
|
||||
|
||||
(defmethod print-object ((ia interaction) s)
|
||||
(format s "<interaction ~s>" (messages ia)))
|
||||
(shape:print-fields ia s 'messages))
|
||||
|
||||
(defmethod core:send ((ia interaction) msg)
|
||||
(util:lgd msg)
|
||||
(push msg (messages ia)))
|
||||
|
||||
(defun cookie-data (ia)
|
||||
(let ((c nil))
|
||||
c))
|
||||
|
||||
;;;; response definitions
|
||||
|
||||
(defvar *html-response-class* nil)
|
||||
|
@ -31,6 +35,7 @@
|
|||
(defclass response ()
|
||||
((context :reader context :initarg :context)
|
||||
(env :reader env :initarg :env)
|
||||
(bakers :accessor bakers :initform nil)
|
||||
(ctype :reader ctype :allocation :class)))
|
||||
|
||||
(defgeneric render-content (resp msg))
|
||||
|
@ -67,11 +72,18 @@
|
|||
(defun html-response-class (html-responder)
|
||||
(or html-responder *html-response-class* 'html-response))
|
||||
|
||||
(defun make-headers (resp iact)
|
||||
(let ((headers (list :content-type (ctype resp))))
|
||||
(dolist (cdata (cookie-data iact))
|
||||
(setf headers
|
||||
(cons :set-cookie (cons (render-cookie resp cdata) headers))))
|
||||
headers))
|
||||
|
||||
(defun render (resp iact)
|
||||
; pre-process special message heads, e.g. (:system :error ...)
|
||||
; => set status code, provide additional data elements
|
||||
; set additional headers
|
||||
(let ((headers (list :content-type (ctype resp)))
|
||||
(let ((headers (make-headers resp iact))
|
||||
(rcode 200))
|
||||
#'(lambda (responder)
|
||||
(let ((writer (funcall responder (list rcode headers))))
|
||||
|
@ -81,3 +93,6 @@
|
|||
|
||||
(defun render-not-found(resp)
|
||||
(list 404 '(:content-type "text/plain") '("Not found")))
|
||||
|
||||
(defun render-cookie (resp cdata)
|
||||
"DEMO=1234567; Path=/; Domain=testing.cyberscopes.org")
|
||||
|
|
Loading…
Add table
Reference in a new issue