Response
Best Practice
To simplify debugging, it is better to use structured logging and include a request id into all log messages and HTTP
server response.
Adding such request id is as simple as adding a method for reblocks/server:handle-http-request
generic-function:
(defmethod reblocks/server:handle-http-request :around ((server t) env)
(let ((request-id (princ-to-string
(uuid:make-v4-uuid))))
(reblocks/response:add-header :x-request-id
request-id)
(log4cl-extras/context:with-fields (:request-id request-id)
(call-next-method))))
Here we use log4cl-extras/context:with-fields
macro for structured logging and reblocks/response:add-header
to add the X-Request-Id
header to webserver's response.
Also, you might want to define a method for reblocks/error-handler:on-error
generic-function and show
current request-id to the user. This way he could provide id to support simplifying issue investigation.