Skip to content

Commit

Permalink
Put :duration in the request
Browse files Browse the repository at this point in the history
  • Loading branch information
swlkr committed May 1, 2020
1 parent e0a18dc commit fdb194a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/joy/logger.janet
Expand Up @@ -69,9 +69,8 @@


(defn response-struct [request response start-seconds end-seconds]
(let [duration (string/format "%.4fms" (- end-seconds start-seconds))
{:status status} response
{:method method :uri uri} request
(let [{:status status} response
{:method method :uri uri :duration duration} request
method (string/ascii-upper method)
content-type (or (get-in response [:headers "Content-Type"])
(get-in response [:headers "content-type"]))]
Expand All @@ -88,6 +87,7 @@
(log (request-struct request options))
(def response (handler request))
(def end-seconds (os/clock))
(put request :duration (string/format "%.4fms" (- end-seconds start-seconds)))
(when response
(log (response-struct request response start-seconds end-seconds)))

Expand Down

0 comments on commit fdb194a

Please sign in to comment.