   
   (OPTIONS [(str url-prefix "/trackers/:ids/events") :ids #"([0-9]+,?)+"] [ids]
        (-> #'success-handler
-           (wrap-cors-headers "GET")
+           (wrap-cors-headers "GET" )
            (wrap-request-logger)))
   (GET [(str url-prefix "/trackers/:ids/events") :ids #"([0-9]+,?)+"] [ids]
        (-> (fn [request] (client-api/fetch-events (merge request {:tracker_ids ids})))

  
  (OPTIONS (str url-prefix "/events") []
       (-> #'success-handler
           (wrap-cors-headers "GET")
           (wrap-request-logger)))
  (GET (str url-prefix "/events") []
       (-> #'client-api/fetch-events
           (wrap-cors-headers "GET")
           (wrap-request-logger)
           )))

  "Logs each incoming request"
  [app]
  (fn [request]
    (let [counter (swap! request-counter inc)
          request-method (:request-method request)
          uri (:uri request)
          query-params (:query-params request)
          start (System/currentTimeMillis)]
      (info (str "REQUEST:" counter)
            request-method uri ":query-params" query-params)
      (let [response (app request)
            duration (- (System/currentTimeMillis) start)
            status (:status response)]
        (info (str "RESPONSE:" counter)
              (str "duration: " duration " msec")
              status)
        response)
    )))

(def url-prefix "/v1-dev")
