Advertisement
Guest User

Untitled

a guest
Jan 27th, 2019
224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (ns live-update.handler
  2.   (:require [compojure.core :refer :all]
  3.             [compojure.route :as route]
  4.             [ring.middleware.defaults :refer [wrap-defaults site-defaults]]
  5.             [clj-http.client :as client]))
  6.  
  7.  
  8. (comment
  9.  
  10.   (:body
  11.    (client/post "http://localhost:3000"
  12.                 {:form-params
  13.                  {:some-edn
  14.                   (pr-str
  15.                    '(do
  16.                       (in-ns live-update.handler) ;;getting rid of this and do will return "#'clojure.core/hello"
  17.                       (defn hello
  18.                         []
  19.                         "hi there")))}}))
  20.  
  21.   (:body (client/get "http://localhost:3000")))
  22.  
  23.  
  24. (defn hello
  25.   []
  26.   "hey")
  27.  
  28. (defroutes app-routes
  29.   (GET "/" [] (#'hello))
  30.   (POST "/" [some-edn] (pr-str (eval (clojure.core/read-string some-edn))))
  31.   (route/not-found "Not Found"))
  32.  
  33. (def app
  34.   (wrap-defaults app-routes (assoc-in site-defaults [:security :anti-forgery] false)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement