Skip to content

Instantly share code, notes, and snippets.

@tobias
Created January 30, 2015 21:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tobias/ee88135ea617c262b6a6 to your computer and use it in GitHub Desktop.
Save tobias/ee88135ea617c262b6a6 to your computer and use it in GitHub Desktop.
(defn url-response
"Return a response for the supplied URL."
{:added "1.2"}
[^URL url]
(if-let [info (resource-info url)]
(letfn [(deref* [v] (if (delay? v) @v v))]
(if-not (deref* (:directory? info))
(-> (response (deref* (:content info)))
(content-length (deref* (:content-length info)))
(last-modified (deref* (:last-modified info))))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment