Browse files

Fix inconsistency in form params.

In order to allow using one querystring for both the Go and Clojure versions of this code, we're using
underscores in the form params.
  • Loading branch information...
1 parent aa14f4f commit 09b6e5c3e6ddc591195cbd35a606e4e9865d42e6 @mattdeboard committed Feb 8, 2014
Showing with 6 additions and 6 deletions.
  1. +1 −1 benchmark/sample_post_data.txt
  2. +5 −5 clj/eventcapture/src/eventcapture/handler.clj
View
2 benchmark/sample_post_data.txt
@@ -1 +1 @@
-event-type=test&ext-ref=abc&user-ref=dude3&data={"a": 1}
+event_type=test&ext_ref=abc&user_ref=dude3&data={"a": 1}
View
10 clj/eventcapture/src/eventcapture/handler.clj
@@ -57,12 +57,12 @@
(defn handle-event-post [event-type ext-ref user-ref data]
(rule (string? event-type)
- [:event-type "Event type must be a non-empty string"])
+ [:event_type "Event type must be a non-empty string"])
(rule (not (strings/blank? event-type))
- [:event-type "Event type must be non-empty string"])
+ [:event_type "Event type must be non-empty string"])
(rule (string? data) [:data "Data must be a string."])
(rule (json/read-str data) [:data "Data must be a string."])
- (if (errors? :event-type :data)
+ (if (errors? :event_type :data)
(server-error (get-errors))
(insert-event {:event_type event-type
:ext_ref ext-ref
@@ -71,8 +71,8 @@
(defroutes app-routes
(GET "/" [] "It works!")
- (POST "/capture" [event-type ext-ref user-ref data]
- (handle-event-post event-type ext-ref user-ref data))
+ (POST "/capture" [event_type ext_ref user_ref data]
+ (handle-event-post event_type ext_ref user_ref data))
(route/resources "/")
(route/not-found "Not Found"))

0 comments on commit 09b6e5c

Please sign in to comment.