Fork me on GitHub
#ring-swagger
<
2017-01-31
>
ikitommi07:01:15

[metosin/compojure-api "1.2.0-alpha3”] is out: class-based exception handling, latest Muuntaja and the inline help.

ikitommi07:01:56

@borkdude you can now list all the restructuring keys with descriptions from repl. The :middleware example:

ikitommi07:01:24

(require '[ :as help])
(help/help :meta :middleware)
------------------------------------------------------------

:middleware

Applies the given vector of middleware to the route.
Middleware is presented as data in a Duct-style form:

1) ring mw-function (handler->request->response)

2) mw-function and it's arguments separately - mw is
   created by applying function with handler and args

(defn require-role [handler role]
  (fn [request]
    (if (has-role? request role)
      (handler request)
      (unauthorized))))

(def require-admin #(require-role % :admin))

(GET "/admin" []
  :middleware [require-admin]
  (ok))

(GET "/admin" []
  :middleware [[require-role :admin]]
  (ok))

(GET "/admin" []
  :middleware [#(require-role % :admin)]
  (ok))

abarylko07:01:20

That's awesome @ikitommi !!!! Kudos to you and to all the collaborators!