From bf4a1755172bdf68a9d8061a751431767669944d Mon Sep 17 00:00:00 2001 From: Jaidyn Ann <10477760+JadedCtrl@users.noreply.github.com> Date: Mon, 9 Dec 2024 21:22:48 -0600 Subject: [PATCH] Tweak logging of requests Minor refactor. --- src/activity-servist.lisp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/activity-servist.lisp b/src/activity-servist.lisp index 799b4d4..8eb9a3f 100644 --- a/src/activity-servist.lisp +++ b/src/activity-servist.lisp @@ -212,7 +212,7 @@ can be found). Uses the callback :FETCH, defined in *CONFIG*." ;;; ———————————————————————————————————————— (defun server (env) "Returns the response data for Clack, given the request property-list ENV." - (nconc *logs* (list env (babel:octets-to-string (alexandria:read-stream-content-into-byte-vector (getf env :raw-body))))) + (setq *logs* (append *logs* (list env (body-contents (getf env :raw-body))))) (let* ((path (pathname-sans-parameters (getf env :request-uri))) (params (pathname-parameters (getf env :request-uri))) (response-function @@ -282,3 +282,9 @@ or “/bear/apple/” or “/bear/”, but not “/bear” (not a directory)." (loop for number across sequence collect (format nil "~X" number)))) + +(defun body-contents (body) + "Given the :RAW-BODY of a Clack ENV, return its contents as a string." + (babel:octets-to-string + (alexandria:read-stream-content-into-byte-vector body))) +