Skip to content

Instantly share code, notes, and snippets.

@rgm
Last active February 19, 2020 17:17
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 rgm/775909ca19002591c8952b823327558d to your computer and use it in GitHub Desktop.
Save rgm/775909ca19002591c8952b823327558d to your computer and use it in GitHub Desktop.
(defn my-regular-handler
[req]
{:status 200 :headers {} :body []})
(defn my-resource-handler
[datasource req]
(let [foo (do-something-with-datasource datasource req)]
{:status 200 :headers {} :body foo}))
(defn make-top-level-handler
[datasource]
(reitit.ring/ring-handler
(reitit.ring/router
[["/" {:get {:handler my-regular-handler}}]
["/get-thing" {:get {:handler (partial my-resource-handler datasource)}}]])
(reitit.ring/routes
(reitit.ring/create-resource-handler {:path "/"})
(reitit.ring/create-default-handler))
{:middleware [,,,]}))
(defmethod ig/init-key ::app
[_ {:keys [datasource]}]
(make-top-level-handler datasource))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment