A Clojure library designed to convert ring requests into cURL commands.
It's main purpose is in debugging applications, as it easily allows you to replay requests against services.
ring-curl is available as a Maven artifact from Clojars.
(:require [ring-curl.core :as ring-curl])
(ring-curl/to-curl request)
; or with options
(ring-curl/to-curl request {:some-option "the-value"})
The following options can be used to modify the output, see the cURL man page for more details about exactly what each option will do.
:verbose?
A truthy value adds the -v curl flag to the output.
:very-silent?
A truthy value adds the -s curl flag to the output.
:silent?
A truthy value adds the -s and -S curl flags to the output.
:no-proxy
A sequence of strings will add the --noproxy "<vals>" curl flag to the output.
:progress-bar?
A truthy value adds the -# curl flag to the output.
:insecure?
A truthy value adds the -k curl flag to the output.
:connect-timeout
A integer value adds the --connect-timeout <val> curl flag to the output.
:max-time
A integer value adds the -m <val> curl flag to the output.
:no-buffer?
A truthy value adds the -N curl flag to the output.
:output
A string value adds the -o "<val>" and --create-dirs curl flags to the output.
:retry
A interger value adds the --retry <val> curl flag to the output.
:dump-headers
A string value adds the -D "<val>" curl flag to the output.
There is middleware included to automatically log every request as curl. This middleware should be the last middleware in the chain, this will ensure the request has been properly modified by all the other middleware.
(require [ring-curl.middleware :refer :all])
(defn handler [request]
  (response {:foo "bar"}))
(def app
  (wrap-curl-logging handler))
You can replace the xml and json writers with your own by binding:
(:require [ring-curl.core :as ring-curl])
(binding [ring-curl/write-json my-custom-function]
  (ring-curl/to-curl request))
(binding [ring-curl/write-xml my-custom-function]
  (ring-curl/to-curl request))
If you use clj-http you can use the convert function under the ring-curl.clj-http
namespace to convert it to a ring request. This will allow it to be printed correctly as curl by the core namespace.
If you would like to add a feature/fix a bug for us please create a pull request. Be sure to include or update any tests if you want your pull request accepted.
Copyright © 2014 - 2018 Christopher Martin
Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.
Can you improve this documentation?Edit on GitHub
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs | 
| ← | Move to previous article | 
| → | Move to next article | 
| Ctrl+/ | Jump to the search field |