|
|
|
@ -35,15 +35,20 @@
|
|
|
|
|
(fn [request]
|
|
|
|
|
(when (= :get (:request-method request)) (handler request))))
|
|
|
|
|
|
|
|
|
|
(defn wrap-log-request [handler]
|
|
|
|
|
(defn wrap-log-transactions [handler]
|
|
|
|
|
(fn [request]
|
|
|
|
|
(-> request
|
|
|
|
|
(select-keys [:headers :protocol :request-method :uri])
|
|
|
|
|
(update :headers get "x-forwarded-for")
|
|
|
|
|
(vals)
|
|
|
|
|
(conj "request:")
|
|
|
|
|
((partial apply println)))
|
|
|
|
|
(handler request)))
|
|
|
|
|
(let [response (handler request)]
|
|
|
|
|
(println
|
|
|
|
|
(get-in request [:headers "x-forwarded-for"])
|
|
|
|
|
"-"
|
|
|
|
|
(str (java.util.Date.))
|
|
|
|
|
"-"
|
|
|
|
|
(:request-method request)
|
|
|
|
|
(:uri request)
|
|
|
|
|
(:protocol request)
|
|
|
|
|
"-"
|
|
|
|
|
(:status response))
|
|
|
|
|
response)))
|
|
|
|
|
|
|
|
|
|
(defn wrap-not-found [handler] (fn [request] (or (handler request) not-found)))
|
|
|
|
|
|
|
|
|
@ -58,7 +63,7 @@
|
|
|
|
|
(wrap-not-modified)
|
|
|
|
|
(wrap-only-gets)
|
|
|
|
|
(wrap-not-found)
|
|
|
|
|
(wrap-log-request)
|
|
|
|
|
(wrap-log-transactions)
|
|
|
|
|
(run-jetty {:port port})))
|
|
|
|
|
(println "usage: bitgloo port content-path")))
|
|
|
|
|
|
|
|
|
|