Skip to content

Instantly share code, notes, and snippets.

@rlander
Last active October 2, 2019 14:48
Show Gist options
  • Select an option

  • Save rlander/a0375b06f2b92b3298c67c43352776a5 to your computer and use it in GitHub Desktop.

Select an option

Save rlander/a0375b06f2b92b3298c67c43352776a5 to your computer and use it in GitHub Desktop.

Revisions

  1. rlander revised this gist Oct 2, 2019. 3 changed files with 16 additions and 0 deletions.
    9 changes: 9 additions & 0 deletions interceptors.clj
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,9 @@
    (ns myapi.interceptors)

    (def user-auth
    {:before (fn [context]
    (update-in context :password h/encrypt-password))
    :after (fn [context]
    (dissoc context [:password]))})

    (def interceptors [user-auth])
    5 changes: 5 additions & 0 deletions routes.clj
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    (ns myapi.routes)

    (def routes
    (start-server ...
    (mount ::myapi.my-service ::myapi.interceptors)))
    2 changes: 2 additions & 0 deletions services.clj
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,5 @@
    (ns myapi.services)

    (defn fetch [id params]
    (db/select-one id params))

  2. rlander created this gist Oct 2, 2019.
    8 changes: 8 additions & 0 deletions services.clj
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,8 @@
    (defn fetch [id params]
    (db/select-one id params))

    (defn fetch* [params]
    (db/select params))

    (defn create! [data params]
    (db/insert! data params))