https://github.com/christoph-frick/relative-clj-http
Helpers to provide defaults and relative modifications around clj-http (only client for now)
https://github.com/christoph-frick/relative-clj-http
clj-http clojure
Last synced: 8 months ago
JSON representation
Helpers to provide defaults and relative modifications around clj-http (only client for now)
- Host: GitHub
- URL: https://github.com/christoph-frick/relative-clj-http
- Owner: christoph-frick
- License: mit
- Created: 2018-03-19T07:45:43.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2022-06-07T19:55:08.000Z (about 4 years ago)
- Last Synced: 2025-10-21T21:04:53.281Z (8 months ago)
- Topics: clj-http, clojure
- Language: Clojure
- Size: 65.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# relative-clj-http
Provide tools to keep a config map around a default
[clj-http](https://github.com/dakrone/clj-http) request and do relative
manipulation to it -- for now or maybe ever: client only.
[](https://clojars.org/net.ofnir/relative-clj-http)
[](https://cljdoc.org/d/net.ofnir/relative-clj-http/CURRENT)
## Usage
Some examples:
```clojure
; require
user=> (require '[relative-clj-http.client :as c])
nil
; a default config for convenience
user=> c/default-config
{:base-url "http://localhost:8080"
:request {:as :auto :coerce :always :debug false :throw-exceptions false}}
; create a config and adjust the base
user=> (def config (-> c/default-config (c/cd "http://httpbin.org")))
#'user/config
user=> config
{:base-url "http://httpbin.org"
:current-url "http://httpbin.org"
:previous-url "http://httpbin.org"
:request {:as :auto :coerce :always :debug false :throw-exceptions false}}
; relative request with that config
user=> (c/request config :get "/get")
{:body "{\n \"args\": {}, \n \"headers\": {\n \"Accept-Encoding\": \"gzip, deflate\", ..."
:content-type :application/json
:status 200
; ...
```
## License
Copyright © 2019 Christoph Frick
Released under the MIT License: http://www.opensource.org/licenses/mit-license.php