Permalink
Newer
100644
23 lines (18 sloc)
513 Bytes
|
cbeebac
|
||
| 1 | ; A example of modular construction of Ring apps. | |
| 2 | ||
| 3 | (ns ring.example.wrapping | |
| 4 | (:use (ring.handler dump) | |
| 5 | (ring.middleware stacktrace file-info file) | |
| 6 | (ring.adapter jetty) | |
|
c5eceba
|
||
| 7 | (clojure.contrib except))) | |
|
cbeebac
|
||
| 8 | ||
| 9 | (defn wrap-error [app] | |
| 10 | (fn [req] | |
| 11 | (if (= "/error" (:uri req)) | |
| 12 | (throwf "Demonstrating ring.middleware.stacktrace") | |
| 13 | (app req)))) | |
| 14 | ||
| 15 | (def app | |
| 16 | (-> handle-dump | |
|
c5eceba
|
||
| 17 | wrap-error | |
|
f2f4229
|
||
| 18 | (wrap-file "example/public") | |
|
cbeebac
|
||
| 19 | wrap-file-info | |
|
c5eceba
|
||
| 20 | wrap-stacktrace)) | |
|
cbeebac
|
||
| 21 | ||
| 22 | (run-jetty app {:port 8080}) |