Responses as JSON
This commit is contained in:
parent
7590531d03
commit
120b820d8e
|
@ -40,15 +40,20 @@
|
|||
|
||||
(defmethod render-result ((res result/success))
|
||||
(with-slots (message msg-id) res
|
||||
(cl-json:encode-json
|
||||
`((STATUS . "OK")
|
||||
(MESSAGE . ,message)
|
||||
(MSGID . ,msg-id)))
|
||||
(let ((msg (if message (format nil ":~A" message) ""))
|
||||
(msgid (if msg-id (format nil " (~A)" msg-id) "")))
|
||||
(format nil "OK~A~A" msgid msg))))
|
||||
|
||||
(defmethod render-result ((res result/error))
|
||||
(with-slots (message msg-id) res
|
||||
(let ((msg (if message (format nil ":~A" message) ""))
|
||||
(msgid (if msg-id (format nil " (~A)" msg-id) "")))
|
||||
(format nil "ERROR~A~A" msgid msg))))
|
||||
(cl-json:encode-json
|
||||
`((STATUS . "ERROR")
|
||||
(MESSAGE . ,message)
|
||||
(MSGID . ,msg-id)))))
|
||||
|
||||
(defgeneric parse-message (sender service api-version message msg-id)
|
||||
(:documentation "Given an incoming message, turn it into the appropriate request."))
|
||||
|
@ -122,3 +127,10 @@
|
|||
(format nil "backplane-~A" (machine-instance))
|
||||
:mechanism :sasl-plain)
|
||||
backplane))))
|
||||
|
||||
;;;; nope...capture the var name and make sure it gets closed, but still pass it in
|
||||
(defmacro with-backplane (backplane &rest ops)
|
||||
(let ((bp-sym (gensym)))
|
||||
`(let ((,bp-sym ,backplane))
|
||||
(unwind-protect (progn ,@ops)
|
||||
(cl-xmpp:disconnect ,bp-sym)))))
|
||||
|
|
Loading…
Reference in New Issue