 
 (defn- detect-language
   "Lookup in the request to find out what should be the default language to serve"
-  [request]
-  :en)
+  [request available-languages]
+  (let [accept-language (get  (:headers request) "accept-language")
+        parsed-languages (map (comp keyword first) (map #(clojure.string/split % #";")
+                                                        (clojure.string/split accept-language #",")))
+        only-available (filter #(contains? available-languages %) parsed-languages)]
+
+    (or (first only-available) default-language)))
 
 (defn guest-list
   "Page showing the list of guests, needs to be authenticated"

(defroutes app-routes
  (GET "/" [] (render-page :initial :en))
  (GET "/enter" [] (render-page :initial :en))
  (GET "/main" request (render-page :home (detect-language request)))
  (GET "/guests" request (guest-list request)))

(def app


(def ^:private security (= (env :secure) "true"))
(def ^:private default-port 3000)
(def ^:private default-language :en)
(def ^:private available-languages #{:en :it})

(defn- get-port
  []
