|
@@ -1,12 +1,35 @@
|
|
|
(ns attendant.handler
|
|
|
(:require
|
|
|
- [compojure.core :refer [ANY defroutes OPTIONS]]
|
|
|
+ [attendant.handlers.playlist :refer [playlist]]
|
|
|
+ [attendant.handlers.witwibw :refer [witwibw]]
|
|
|
+ [clojure.string :as string]
|
|
|
+ [compojure.core :refer [ANY context defroutes OPTIONS routes]]
|
|
|
[compojure.route :refer [not-found]]
|
|
|
- [ring.util.response :refer [header]]))
|
|
|
+ [ring.util.response :refer [header response]]))
|
|
|
+
|
|
|
+(def simple-functions
|
|
|
+ [["/witwibw" witwibw]])
|
|
|
+
|
|
|
+(def complex-functions
|
|
|
+ [["/playlist" playlist]])
|
|
|
|
|
|
(defroutes app
|
|
|
(OPTIONS "*" [] "")
|
|
|
(ANY "/" [] "attendant server")
|
|
|
+
|
|
|
+ (->> simple-functions
|
|
|
+ (map #(ANY (first %) [] (second %)))
|
|
|
+ (apply routes))
|
|
|
+
|
|
|
+ (->> complex-functions
|
|
|
+ (map #(context (first %) [] ((second %))))
|
|
|
+ (apply routes))
|
|
|
+
|
|
|
+ (ANY "/directory" [] (->> (concat simple-functions complex-functions)
|
|
|
+ (map first)
|
|
|
+ (string/join "\n")
|
|
|
+ response))
|
|
|
+
|
|
|
(not-found "nothing here (yet)"))
|
|
|
|
|
|
(defn make-handler []
|