Blob


1 # Gemini library for clojure
3 `gemini.core` is a clojure library to make Gemini requests.
6 ## Usage
8 ```clojure
9 user=> (require '[gemini.core :as gemini])
10 ```
12 #### fetch
14 `fetch` makes a Gemini request and returns a map with `:request`,
15 `:meta`, `:code` and `:body` as keys, or `:error` if an error occur.
17 The request needs to be closed afterwards using `close`, or calling
18 the `.close` method on the `:request` object.
20 ```clojure
21 user=> (gemini/fetch "gemini://gemini.circumlunar.space/")
22 {:request
23 #object[com.omarpolo.gemini.Request 0x3b270767 "com.omarpolo.gemini.Request@3b270767"],
24 :meta "gemini://gemini.circumlunar.space/",
25 :code 31,
26 :body
27 #object[java.io.BufferedReader 0x49358b66 "java.io.BufferedReader@49358b66"]}
28 ```
30 #### body-as-string!
32 Read all the response into a string and returns it. It also closes
33 the request automatically.
35 ```clojure
36 user=> (-> (gemini/fetch "gemini://gemini.circumlunar.space/")
37 gemini/body-as-string!)
38 "# Project Gemini\n\n## Overview\n\nGemini is a new internet protocol which..."
39 ```
41 #### close
43 Closes a request.
45 #### with-request
47 Like `with-open`, but specifically for the requests:
49 ```clojure
50 user=> (with-request [req (fetch "gemini://gemini.circumlunar.space/")]
51 ,,,)
52 ```