   (route/not-found "Not found"))
 
 (def app (middleware/app-handler
-          [(wrap-rpc (wrap-friend app-routes))]
-          :middleware []
-          :access-rules []))
+          [(wrap-friend (wrap-rpc app-routes))]))
 
 (def war-handler (middleware/war-handler app))

(ns wlmmap.handler
  (:import (java.io File))
  (:require [clojure.data.json :as json]
            [clojure.string :as str]
            [cemerick.friend :as friend]

  "http://toolserver.org/~erfgoed/api/api.php?action=search&format=json&limit=5000&props=lat|lon|name|registrant_url|id|image|lang|monument_article")

(def db-options
  (atom
   (sort
    (map #(let [[_ [cntry lng]] %] (str cntry " / " lng)) lang-pairs))))

(defremote set-db-options-from-lang [lang]
  (let [languages-json
        (json/read-str (slurp (str "resources/public/cldr/" lang "/languages.json"))
                       :key-fn keyword)
        languages
        (get-in languages-json
                [:main (keyword lang) :localeDisplayNames :languages])
        territories-json
        (json/read-str (slurp (str "resources/public/cldr/" lang "/territories.json"))
                       :key-fn keyword)
        countries
        (get-in territories-json
                [:main (keyword lang) :localeDisplayNames :territories])]
    ;; Check if localization is available for the language
    (swap! db-options
           (fn [_] 
             (sort (map #(let [[_ [cntry lng]] %
                               cplx (re-seq #"([^-]+)-(.+)" cntry)]
                           (if cplx
                             (let [[_ bare suffix] (first cplx)]
                               (vector (str ((keyword (clojure.string/upper-case bare)) countries)
                                            " (" suffix ") / " ((keyword lng) languages))
                                       (str cntry "/" lng)))
                             (vector (str ((keyword (clojure.string/upper-case cntry)) countries)
                                          " / " ((keyword lng) languages))
                                     (str cntry "/" lng))))
                        lang-pairs))))))

(defremote get-lang-list [lang]
  (remove nil?
