Response

Best Practice

To simplify debugging, it is better to use structured logging and include a request ID in all log messages and HTTP server responses.

Adding such a request ID is as simple as adding a method for the 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 the log4cl-extras/context:with-fields macro for structured logging and reblocks/response:add-header to add the X-Request-Id header to the webserver's response.

Also, you might want to define a method for the reblocks/error-handler:on-error generic function and show the current request ID to the user. This way they could provide the ID to support, simplifying issue investigation.