diff options
author | Ludovic Courtès <ludo@gnu.org> | 2019-10-23 15:37:15 +0200 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2019-10-23 15:37:15 +0200 |
commit | c8c34f8ee3a62ab3d86a65bae2a4ddafd619088f (patch) | |
tree | d9df3ce2698ad9b722a195e0239615495ae5dba4 | |
parent | 15fc2d76919171a5f3ef1f32654e9509f3b246db (diff) | |
download | cuirass-c8c34f8ee3a62ab3d86a65bae2a4ddafd619088f.tar cuirass-c8c34f8ee3a62ab3d86a65bae2a4ddafd619088f.tar.gz |
http: Serve evaluation logs at /eval/ID/log/raw.
* src/cuirass/base.scm (evaluation-log-file): Export.
* src/cuirass/http.scm (url-handler)[respond-gzipped-file]: New
procedure.
Add handler for /eval/ID/log/raw.
-rw-r--r-- | src/cuirass/base.scm | 2 | ||||
-rw-r--r-- | src/cuirass/http.scm | 15 |
2 files changed, 17 insertions, 0 deletions
diff --git a/src/cuirass/base.scm b/src/cuirass/base.scm index 3dbc5f4..c1e6383 100644 --- a/src/cuirass/base.scm +++ b/src/cuirass/base.scm @@ -63,6 +63,8 @@ build-packages prepare-git process-specs + evaluation-log-file + ;; Parameters. %package-cachedir %gc-root-directory diff --git a/src/cuirass/http.scm b/src/cuirass/http.scm index b6a4358..9f5fdce 100644 --- a/src/cuirass/http.scm +++ b/src/cuirass/http.scm @@ -24,6 +24,7 @@ (define-module (cuirass http) #:use-module (cuirass config) #:use-module (cuirass database) + #:use-module ((cuirass base) #:select (evaluation-log-file)) #:use-module (cuirass utils) #:use-module (cuirass logging) #:use-module (srfi srfi-1) @@ -211,6 +212,14 @@ Hydra format." #:body (call-with-input-file file-path get-bytevector-all)) (respond-not-found file-name)))) + (define (respond-gzipped-file file) + ;; Return FILE with 'gzip' content-encoding. + (respond `((content-type . (text/plain (charset . "UTF-8"))) + (content-encoding . (gzip))) + ;; FIXME: FILE is potentially big so it'd be better to not load + ;; it in memory and instead 'sendfile' it. + #:body (call-with-input-file file get-bytevector-all))) + (define (respond-build-not-found build-id) (respond-json-with-error 404 @@ -438,6 +447,12 @@ Hydra format." (#:link . ,(string-append "/eval/" id))))))) (respond-html-eval-not-found id)))) + (("eval" (= string->number id) "log" "raw") + (let ((log (and id (evaluation-log-file id)))) + (if (and log (file-exists? log)) + (respond-gzipped-file log) + (respond-not-found (uri->string (request-uri request)))))) + (("search") (let* ((params (request-parameters request)) (query (and=> (assq-ref params 'query) uri-decode)) |