                         (if-let [root (options :root)]
                           {:path root}))})
 
-(defn session-request
-  "Reads current HTTP session map and adds it to :session key of the request."
+(defn- bare-session-request
   [request & [{:keys [store cookie-name]}]]
   (let [req-key  (get-in request [:cookies cookie-name :value])
         session  (store/read-session store req-key)

    (if (and new-session-key (not= session-key new-session-key))
      (assoc response :cookies (merge (response :cookies) cookie))
      response)))

(defn wrap-session
  "Reads in the current HTTP session map, and adds it to the :session key on

     (wrap-session handler {}))
  ([handler options]
     (let [options (session-options options)]
       (fn [request]
         (let [new-request (session-request request options)
               session-key (:session/key new-request)
               response (-> new-request
                            handler
                            (assoc :session/key session-key))]
           (when (seq (dissoc response :session/key))
             (session-response response options)))))))
