Posted on 13 July, 2015 by Eric Bailey
Tags: hack, clojure, web-service, open-source

As a follow-up to my previous post about icanhazip.com, I figured it bears mentioning I've since set up my own IP echo service and am running it at ip.ericb.me.

Its excruciatingly simple Clojure source looks something like this:

(defroutes app
  (GET "/" {{x-real-ip "x-real-ip"} :headers}
    {:status  200
     :headers {"Content-Type" "text/plain"}
     :body    x-real-ip}))

(defn -main [& args]
  (->> (or (some-> (env :port) (Integer/parseInt)) 5000)
       (hash-map :port)
       (run-server app)))