Skip to content

Instantly share code, notes, and snippets.

@reborg
Created July 4, 2017 13:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save reborg/b04aab004737be36249074a819cbec2f to your computer and use it in GitHub Desktop.
Save reborg/b04aab004737be36249074a819cbec2f to your computer and use it in GitHub Desktop.
;; browser req
(defn fetch [template placeholders]
(let [snippet "<switching-to> closing script"]
(POST "/snippets"
{:params {:template "template" :placeholders "placeholders"}
:handler #(.log js/console (str "ok: " %))
:error-handler #(.log js/console (str "error: " %))})
(reduce-kv (fn [s k v] (s/replace s (re-pattern k) v)) snippet placeholders)))
;; server handler
(defroutes app-routes
; (POST "/snippets" request {:body (str "got request with " request)})
; (POST "/snippets" {body :body} {:body (str "got body " (slurp body))})
(POST "/snippets" {body-params :body-params} {:body (str "got params " body-params)})
(resources "/"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment