Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix issues with plan change/body logging

Request logging was slurping the body, which meant
it couldn't be read later - this was affecting
plan change. Make the logger re-generate a reader
for the body using java magic after slurping.
Note: Sub optimal for large bodies.
  • Loading branch information...
commit 4b2a3aa9f6c3c3d4c1a51fa5f17c14bfa3b6a4b3 1 parent 4f9775a
@lstoll lstoll authored
Showing with 9 additions and 3 deletions.
  1. +9 −3 src/addon/core.clj
View
12 src/addon/core.clj
@@ -5,6 +5,7 @@
[ring.middleware.cookies]
[hiccup.core]
[ring.util.response])
+ (:import [java.io ByteArrayInputStream])
(:require [compojure.route :as route]
[clj-json.core :as json]
[clojure.contrib.http.agent :as http]
@@ -21,10 +22,13 @@
(defn wrap-logging [f]
(fn [{:keys [query-params headers body] :as req} & args]
+ (let [bstr (slurp body)
+ req* (assoc req
+ :body (ByteArrayInputStream. (.getBytes bstr)))]
(println "PARAMS" (pr-str query-params))
(println "HEADERS" (pr-str headers))
- (println "BODY" (slurp body ))
- (apply f req args)))
+ (println "BODY" bstr)
+ (apply f req* args))) )
(defn sha1 [plaintext-str]
(let [plaintext-bytes (.getBytes plaintext-str)
@@ -35,6 +39,8 @@
digest-bytes))))
(defn sso-page [header id email]
+ (prn @resources)
+ (prn id)
(html
[:body
header
@@ -75,7 +81,7 @@
(defn plan-change [id body]
(dosync
(if (@resources id)
- (alter resources assoc id (:plan body))
+ (alter resources assoc id (get body "plan"))
(-> (response "Not found")
(status 404)))))
Please sign in to comment.
Something went wrong with that request. Please try again.