Skip to content

Instantly share code, notes, and snippets.

@swlkr
Created September 28, 2017 04:21
Show Gist options
  • Select an option

  • Save swlkr/584160c1365943384355d69c5f87b1fd to your computer and use it in GitHub Desktop.

Select an option

Save swlkr/584160c1365943384355d69c5f87b1fd to your computer and use it in GitHub Desktop.
(def protected-routes (-> (get "/" (fn [r] "GET /"))
(get "/sign-out" (fn [r] "GET /sign-out"))))
(defn middleware [handler]
(fn [request]
(if (= 1 2)
(handler request)
(throw (Exception. "Nope")))))
(def routes (-> (wrap-routes middleware protected-routes)
(get "/sign-up" (fn [r] "GET /sign-up"))
(post "/users" (fn [r] "POST /users"))
(put "/users/:id" (fn [r] "PUT /users"))
(patch "/users/:user-id" (fn [r] "PATCH /users"))
(delete "/users/:uid" (fn [r] "DELETE /users"))
(not-found (fn [r] "not found"))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment