Is it possible to attach metadata for a sub-path in the tapped value? I have some http response in the making often of the format:
{:status some-status
:headers {"Content-Type" "hiccup"}
:body <some-hiccup-vector>}
I have a wrap-tap-request-response middleware:
(defn- tap-request-response [handler]
(fn [request]
(tap> request)
(let [response (handler request)]
(tap> response)
response)))
I can attach metadata to the response and set default viewer to hiccup, but this fails because response is a map. Can I attach it to :body value of the response instead of the entire response?
Further, is it possible to auto-expand the response body?
I'm pretty sure this isn't supported. Just asking.If the sub value is a vector, you can update it with the viewer metadata:
(update {:body [:h1 "hi"]}
:body vary-meta
assoc :portal.viewer/default :portal.viewer/hiccup)I'm planning to add support for expanding values based on metadata, just haven't gotten around to it yet.
Wow, thanks. Will check out this stuff.
Actually, for the helper, the following is better:
(update {:body [:h1 "hi"]} :body portal.viewer/hiccup)The other way didn't actually work facepalm