From 94559f7626d7e0e8adda2d5627be846c9371a3d0 Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Sat, 29 Feb 2020 09:22:22 +0100 Subject: [PATCH] Add HTTP docs --- README.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/README.md b/README.md index c2069ffa..b29f20e3 100644 --- a/README.md +++ b/README.md @@ -622,6 +622,32 @@ bb ' process 2 ``` +## HTTP + +For making HTTP requests you can use: + +- `slurp` for simple `GET` requests +- [clj-http-lite](https://github.com/borkdude/clj-http-lite) as a library +- `curl` via `clojure.java.shell`. For an example, see the following + subsection. + +### HTTP over Unix sockets + +This can be useful for talking to Docker: + +``` clojure +(require '[clojure.java.shell :refer [sh]]) +(require '[cheshire.core :as json]) +(-> (sh "curl" "--silent" + "--no-buffer" "--unix-socket" + "/var/run/docker.sock" + "http://localhost/images/json") + :out + (json/parse-string true) + first + :RepoTags) ;;=> ["borkdude/babashka:latest"] +``` + ## Differences with Clojure Babashka is implemented using the [Small Clojure