         ;cors-handler))
 
 (defn start-server-on-regular-machine
-    [port]
+    [ring-app port]
     (println "Starting the server at the port: " port)
-    (jetty/run-jetty app {:port (read-string port)}))
+    (jetty/run-jetty ring-app {:port (read-string port)}))
 
 (defn start-server-on-openshift
-    [port host]
+    [ring-app port host]
     (println "Starting the server on openshift at the port: " port " and host: " host)
-    (jetty/run-jetty app {:port (read-string port) :host host}))
+    (jetty/run-jetty ring-app {:port (read-string port) :host host}))
 
 (defn start-server
     "Start server on specified port."
-    [port openshift-port openshift-ip]
-    (if (and openshift-ip openshift-port)
-        (start-server-on-openshift openshift-port openshift-ip)
-        (start-server-on-regular-machine port)))
+    [configuration port openshift-port openshift-ip]
+    (let [ring-app
+        (-> server/handler            ; handle all events
+            (middleware/inject-configuration configuration) ; inject configuration structure into the parameter
+            cookies/wrap-cookies      ; we need to work with cookies
+            http-params/wrap-params   ; and to process request parameters, of course
+            all-cors)]
+        (if (and openshift-ip openshift-port)
+            (start-server-on-openshift       ring-app openshift-port openshift-ip)
+            (start-server-on-regular-machine ring-app port))))
 
 (defn get-and-check-port
     "Accepts port number represented by string and throws AssertionError

          openshift-ip        (System/getenv "OPENSHIFT_CLOJURE_HTTP_IP")
          openshift-port      (System/getenv "OPENSHIFT_CLOJURE_HTTP_PORT")]
        (print-environment-configuration)
        ;(config/override-options-by-cli jenkins-url test-jobs-suffix)
        (println "Finished")))

(defn run-app

          test-jobs-suffix    (options :test-jobs-suffix)
          openshift-ip        (System/getenv "OPENSHIFT_CLOJURE_HTTP_IP")
          openshift-port      (System/getenv "OPENSHIFT_CLOJURE_HTTP_PORT")]
        (let [configuration (config/load-configuration-from-ini "config.ini")]
            (config/override-options-by-cli configuration jenkins-url test-jobs-suffix)
        (start-server configuration (get-port port) openshift-port openshift-ip))))

(defn -main
    "Entry point to the Emender service server."
