Ring middleware to facilitate audit requirements.
Makes use of clout to match routes and execute an fn
of your choice!
Have it write to a db, send a message to a queue, send an email...
(ns foo.bar
(:use compojure.core
[ring.audit.middleware.core :only [wrap-audit-middleware]])
(:require [compojure.handler :as handler]
[compojure.route :as route]))
(defroutes foo-app
(GET "/foo/bar/:id" ...)
(POST "/admin/:id/edit" ...)
(POST "/users" ...))
fn
Must accept two arguments, the ring request map and map of request parameters from clout (see clout documentation)
(defn audit-fn [req params] ... )
wrap-audit-middleware
Audit all routes
(def app
(-> (handler/site foo-app)
(wrap-audit-middleware audit-fn)))
Provide a collection of routes (see clout documentation) to determine if the request should be audited
(def app
(-> (handler/site foo-app) ;; audit all admin member routes and all user routes
(wrap-audit-middleware audit-fn :routes ["/admin/:id/*" "/users/*"])))
Instruct the middleware to audit routes in a future (useful for long running audits)
(def app
(-> (handler/site foo-app)
(wrap-audit-middleware audit-fn :future true)))
Why not both?
(def app
(-> (handler/site foo-app)
(wrap-audit-middleware audit-fn :routes ["/admin/:id/*"] :future true)))
Copyright (C) 2013 Kyle Gann
Distributed under the Eclipse Public License, the same as Clojure.
Can you improve this documentation?Edit on GitHub
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close