From 7752d73216578d5961751b5d0535088d384b4aa6 Mon Sep 17 00:00:00 2001 From: Arnaud Bailly Date: Sat, 25 Jan 2025 10:45:41 +0100 Subject: Move λ-calcul workshop code to subdirectory MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lambda-calcul/clojure/src/lccl/app.clj | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 lambda-calcul/clojure/src/lccl/app.clj (limited to 'lambda-calcul/clojure/src/lccl/app.clj') diff --git a/lambda-calcul/clojure/src/lccl/app.clj b/lambda-calcul/clojure/src/lccl/app.clj new file mode 100644 index 0000000..522d8bf --- /dev/null +++ b/lambda-calcul/clojure/src/lccl/app.clj @@ -0,0 +1,30 @@ +(ns lccl.app + (:require [reitit.ring :as ring-reitit] + [reitit.coercion.malli] + [reitit.ring.malli] + [reitit.dev.pretty :as pretty] + [reitit.ring.middleware.muuntaja :as muuntaja] + [muuntaja.core :as m])) + +(defn eval + [request] + (let [sexpr (slurp (:body request))] + (println "Demande d'évaluation de l'expression :" sexpr) + {:status 200, :body sexpr})) + +(defn api-handler + [] + (ring-reitit/ring-handler + (ring-reitit/router + [["/eval" {:post eval}]] + + {:exception pretty/exception + :data { + :muuntaja m/instance + :middleware [muuntaja/format-response-middleware]}}))) + +(defn app-handler + [] + (ring-reitit/routes (api-handler))) + + -- cgit v1.2.3