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