diff options
| -rw-r--r-- | jurl/init.janet | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/jurl/init.janet b/jurl/init.janet index 0d501ca..ad6c0a4 100644 --- a/jurl/init.janet +++ b/jurl/init.janet @@ -272,6 +272,19 @@ :headers (text/parse-headers res-hdr) :status (handle :response-code)}) +# fast and convenient functions +(defn slurp + [url &opt opts] + (default opts {}) + (def out (request (merge opts {:url url}))) + (assert (= :ok (out :error))) + (out :body)) + +(defn spit + [url body &opt opts] + (default opts {}) + (def out (request (merge opts {:url url :method :post :body body})))) + (defn- merge-request [orig new] (let [mdict |(merge (get orig $ {}) (get new $ {}))] |
