~lucasemmoreira/hitter

67786fd189213c04637f2704008daef487b83c42 — Lucas Moreira 2 years ago 05754ca
fix: web checking (hit)
2 files changed, 6 insertions(+), 8 deletions(-)

D src/curl.janet
M src/hit.janet
D src/curl.janet => src/curl.janet +0 -5
@@ 1,5 0,0 @@
(defn command [url & args]
  (let [cmd @("curl")
        cmd (array/concat cmd args)
        cmd (array/concat cmd url)]
    (os/execute cmd :p )))

M src/hit.janet => src/hit.janet +6 -3
@@ 1,7 1,10 @@
(import ./curl :as curl)
(import http)

(defn status-url [url]
  (curl/command url "-s" "-o /dev/null" "--head" "-w \"%{http_code}\"" "-X" "POST"))
  (when url 
    (get (http/get url) :status)))

(defn status-urls [urls]
  (map (fn [url] (status-url url)) urls))
  (filter (fn [ell] (do (not (nil? ell))))
	  (map (fn [url] (status-url url)) urls)))