-
-
Save borkdude/7ce01912bd8af1dfbc868f7ba82da46b to your computer and use it in GitHub Desktop.
Yada no 404
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(require '[yada.yada :as y]) | |
(require '[bidi.vhosts :refer [vhosts-model]]) | |
(require '[clj-http.client :as client]) | |
(defmacro with-server | |
"Runs resource in server and defines url for use in body" | |
[resource & body] | |
`(let [resource# ~resource | |
vmodel# (vhosts-model [:* ["/api/foo" resource#]]) | |
listener# (y/listener vmodel#) | |
port# (:port listener#) | |
close# (:close listener#) | |
~'url (str "http://localhost:" port# "/api/foo")] | |
~@body | |
(close#))) | |
(comment | |
(with-server (y/resource | |
{:methods {:post {:produces "application/json" | |
:response (fn [ctx] nil)}}}) | |
(println (:status (client/post url))))) ;; 200?? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment