mirror of
https://github.com/penpot/penpot.git
synced 2025-07-16 22:25:15 +02:00
🎉 Add the ability to execute code on the end of http request.
Mainly for register metrics once the main transaction is commited.
This commit is contained in:
parent
c79036aa65
commit
995017df5a
1 changed files with 10 additions and 1 deletions
|
@ -25,6 +25,11 @@
|
||||||
[_]
|
[_]
|
||||||
(ex/raise :type :not-found))
|
(ex/raise :type :not-found))
|
||||||
|
|
||||||
|
(defn- run-hook
|
||||||
|
[hook-fn response]
|
||||||
|
(ex/ignoring (hook-fn))
|
||||||
|
response)
|
||||||
|
|
||||||
(defn- rpc-query-handler
|
(defn- rpc-query-handler
|
||||||
[methods {:keys [profile-id] :as request}]
|
[methods {:keys [profile-id] :as request}]
|
||||||
(let [type (keyword (get-in request [:path-params :type]))
|
(let [type (keyword (get-in request [:path-params :type]))
|
||||||
|
@ -50,7 +55,11 @@
|
||||||
result ((get methods type default-handler) data)
|
result ((get methods type default-handler) data)
|
||||||
mdata (meta result)]
|
mdata (meta result)]
|
||||||
(cond->> {:status 200 :body result}
|
(cond->> {:status 200 :body result}
|
||||||
(fn? (:transform-response mdata)) ((:transform-response mdata) request))))
|
(fn? (:transform-response mdata))
|
||||||
|
((:transform-response mdata) request)
|
||||||
|
|
||||||
|
(fn? (:before-complete mdata))
|
||||||
|
(run-hook (:before-complete mdata)))))
|
||||||
|
|
||||||
(defn- wrap-with-metrics
|
(defn- wrap-with-metrics
|
||||||
[cfg f mdata]
|
[cfg f mdata]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue