                                          ~'server-name (:server-name ~'request)]
                                      (or ~@(for [app sorted]
                                              `(when (matcher ~(:ring-conf app) ~'uri ~'server-name)
-                                                (boxure/call-in-box ~(:box app)
-                                                                    ~(:handler-fn app)
-                                                                    ~'request))))))]
+                                                (boxure/call-in-box
+                                                 ~(:box app)
+                                                 ~(:handler-fn app)
+                                                 ~(if-let [cp (-> app :ring-conf :context-path)]
+                                                    `(update-in ~'request [:uri]
+                                                                #(subs % ~(count cp)))
+                                                    ~'request)))))))]
                     (eval fn-form))
                   (constantly {:status 503 :body "no apps loaded"}))]
     (alter-var-root #'app (constantly handler))))

  configuration. A required key is :handler-sym, which, when evaluated
  inside the box, should be the ring handler function. Optional keys
  are :context-path and :host-regex. The first acts as a filter for
  the first element(s) in the request URI, for example \"/api/v1/\".
  The second is a regular expression, which is matched against the
  server name of the request, for example \".*containium.com\"."
  [{:keys [name project] :as box}]

(defn- clean-ring-conf
  "Updates the ring-conf, in order to ensure some properties of the values."
  [ring-conf]
  (let [result ring-conf
        result (update-in result [:context-path]
                          #(when % (if (= (last %) \/) (apply str (butlast %)) %)))
        result (update-in result [:context-path]
                          #(when % (if (= (first %) \/) % (str "/" %))))]
    result))


(defn upstart-box
