From ef84301f83d2be2bf8fa05040fc0703c0f82cb0f Mon Sep 17 00:00:00 2001 From: Jay McCarthy Date: Tue, 6 Sep 2011 10:23:31 -0600 Subject: [PATCH] JSON timing data --- collects/meta/drdr/render.rkt | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/collects/meta/drdr/render.rkt b/collects/meta/drdr/render.rkt index e274bd4daf..9b4f1e7f50 100644 --- a/collects/meta/drdr/render.rkt +++ b/collects/meta/drdr/render.rkt @@ -282,6 +282,21 @@ [(struct stderr (bs)) `(pre ([class "stderr"]) ,(bytes->string/utf-8 bs))]))) +(define (json-timing req path-to-file) + (let* ([timing-pth (path-timing-log (apply build-path path-to-file))] + [s (file->string timing-pth)] + [s (regexp-replace* (regexp-quote "(") s "[")] + [s (regexp-replace* (regexp-quote ")") s "]")] + [s (format "[~a]" s)]) + (response + 200 #"Okay" + (file-or-directory-modify-seconds timing-pth) + #"application/json" + (list (make-header #"Access-Control-Allow-Origin" + #"*")) + (lambda (out) + (write-string s out))))) + (define (render-log log-pth) (match (log-rendering log-pth) [#f @@ -940,6 +955,7 @@ [("help") show-help] [("") show-revisions] [("diff" (integer-arg) (integer-arg) (string-arg) ...) show-diff] + [("json" "timing" (string-arg) ...) json-timing] [("current" "") show-revision/current] [("current" (string-arg) ...) show-file/current] [((integer-arg) "") show-revision]