Revamps all of the IOL's routing, so that the new history page can share with the rest.

This commit is contained in:
2023-01-12 16:56:40 -08:00
parent ce01a63797
commit 46dd191391
29 changed files with 1294 additions and 1053 deletions

View File

@@ -1,23 +1,30 @@
(ns auto-ap.routes.ezcater
(:require
[clojure.tools.logging :as log]
[compojure.core :refer [context defroutes GET POST wrap-routes]]
[ring.middleware.json :refer [wrap-json-params]]
[auto-ap.ezcater.core :as e]
[ring.util.request :refer [body-string]]))
[auto-ap.logging :as alog]
[ring.middleware.json :refer [wrap-json-params]]))
(defroutes routes
(wrap-routes
(context "/ezcater" []
(GET "/event" request
(log/info (str "GET EVENT " (body-string request) request))
{:status 200
:headers {"Content-Type" "application/json"}
:body "{}"})
(POST "/event" request
(log/info (str "POST EVENT " (body-string request) request))
(e/import-order (:json-params request))
{:status 200
:headers {"Content-Type" "application/json"}
:body "{}"}))
wrap-json-params))
(defn handle-ezcater [{:keys [request-method json-params] :as r}]
(cond
(= :get request-method)
{:status 200
:headers {"Content-Type" "application/json"}
:body "{}"}
(= :post request-method)
(do
(alog/info ::ezcater-request
:json-params json-params)
(e/import-order json-params)
{:status 200
:headers {"Content-Type" "application/json"}
:body "{}"})
:else
{:status 404}))
(def routes {"api/" {"ezcater/" {#"event/?" :ezcater-event}}})
(def match->handler {:ezcater-event (-> handle-ezcater
wrap-json-params)})