What's the recommended way of setting up a route with an interceptor for body-params
? I have this:
["/api/users"
:post [(body-params/body-params)]
;user-handler
:route-name :user-handler
]
with my handler:
(defn user-handler
[{:keys [headers params json-params path-params] :as request}]
{:status 200 :body "/api/users"})
but doesn't seem to workfigured this out
When you compose interceptors, whats the preferred pedestal way? Many interceptors or few interceptors? Example: 1. "light weight interceptors"
(conj common-interceptors
error-handler
coerce-create-transaction-request
with-jdbc-transaction-interceptor!
get-current-user-interceptor!
get-current-system-status-interceptor!
validate-user-balance-interceptor
save-transaction-interceptor!
notify-booking-system-interceptor!)
2. "heavy-weight-interceptors"
(conj common-interceptors
error-handler
coerce-create-transaction-request
handle-create-transaction-interceptor)
I tend to prefer small interceptors where each focuses on a single responsibility but I suppose it depends on context
To me, having small interceptors which focus on a single responsibility makes things more explicit
plus they are easier to reason about, test, etc…
A downside could be performance. E.g., 10 round-trips to the database, instead of just 1
indeed isak, one always has to think about roundtrips 🙂