Skip to content

Instantly share code, notes, and snippets.

@ryancole
Created February 20, 2013 20:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryancole/4999031 to your computer and use it in GitHub Desktop.
Save ryancole/4999031 to your computer and use it in GitHub Desktop.
(defn append-user-data [handler]
(fn [request]
(clutch/with-db database-address
(let [access-token (get-in request [:headers "token"])
view-data (clutch/get-view "api" "users-by-token" {:keys [access-token]})]
(if (= 1 (count view-data))
(handler (assoc request :api-user (:value (first view-data))))
{:status 403
:body "Invalid access token"})))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment