wrestler.handlers
A module for clj-http response handlers
http-codes
A mapping of HTTP code numbers to human-readable keywords.
to-edn
(to-edn response)
A response handler for clj-http responses. In HTTP, every response that
returns with a status code between 200 and 299 is considered a success. If a
response is received that doesn't have a status code in that range a message
will be printed to STDERR. But before that happens the clj-http library will
probably throw an exception anyway and prevent this handler from being called
in the first place.
If the response hash-map contains a :body key that does not refer to nil this
response handler will try to convert the response to clojure data (EDN). If
the server sends a Content-Type header that contains the specification
application/json the data will be parsed with the clojure.data.json library to
get clojure data. Otherwise you will probably get a plain string. Further
parsing of response types (XML etc.) might be implemented in the future.
If the response hash-map doesn't contain a :body key or if it refers to nil
then the complete response hash-map is returned unless the status code is a
key in the hash-map wrestler.handlers.http-codes . In that case the
coresponding value from the hash-map is returned. If this interferes with your
debugging process consider (reset!)ing your response-handler to something
different while debugging.