Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #113 from kenrestivo/print_state

Debug function to print state of Noir routes, middleware, wrappers, etc.
  • Loading branch information...
commit 0a5a7483dc37ab0ebe8937f93c50400915aba08a 2 parents 3482117 + 8cb61ba
@Raynes Raynes authored
Showing with 36 additions and 1 deletion.
  1. +36 −1 src/noir/util/test.clj
View
37 src/noir/util/test.clj
@@ -1,6 +1,7 @@
(ns noir.util.test
"A set of utilities for testing a Noir project"
- (:use clojure.test)
+ (:use clojure.test
+ [clojure.pprint :only [pprint]])
(:require [noir.server :as server]
[noir.session :as session]
[noir.validation :as vali]
@@ -57,3 +58,37 @@
[ring-req]
(let [handler (server/gen-handler options/*options*)]
(handler ring-req)))
+
+
+(defn print-state
+ "Print the state of the noir server's routes/middleware/wrappers.
+ If optional details? arg is truthy, show noir-routes, route-funcs,
+ and status pages too."
+ [& details?]
+ (let [print-func (if details? pprint (comp println pprint sort keys))]
+
+ (println "== Pre-Routes ==")
+ (print-func @noir.core/pre-routes)
+
+ (println "== Routes and Funcs ==")
+ (print-func (merge-with vector @noir.core/noir-routes @noir.core/route-funcs))
+
+ (println "== Post-Routes ==")
+ (pprint @noir.core/post-routes)
+
+ (println "== Compojure-Routes ==")
+ (pprint @noir.core/compojure-routes)
+
+ (println "== Middleware ==")
+ (pprint @noir.server.handler/middleware)
+
+ (println "== Wrappers ==")
+ (pprint @noir.server.handler/wrappers)
+
+ (println "== Memory Store ==")
+ (pprint @noir.session/mem)
+
+ (when details?
+ (do (println "== Status Pages ==")
+ (pprint @noir.statuses/status-pages)))))
+
Please sign in to comment.
Something went wrong with that request. Please try again.