diff options
author | Mathieu Othacehe <othacehe@gnu.org> | 2020-08-02 18:39:35 +0200 |
---|---|---|
committer | Mathieu Othacehe <othacehe@gnu.org> | 2020-08-02 18:39:35 +0200 |
commit | 614ea0576743e7ab83a7b4f82b48f272a67ebbf7 (patch) | |
tree | bbf1ad7229b72bfd760edee77d4cedd76778201f | |
parent | 59c974134f569e476c4b4b17c1b8bce74746c546 (diff) | |
download | cuirass-614ea0576743e7ab83a7b4f82b48f272a67ebbf7.tar cuirass-614ea0576743e7ab83a7b4f82b48f272a67ebbf7.tar.gz |
http: Rationalize build id conversion.
* src/cuirass/http.scm (url-handler): Handle the id -> number conversion
directly in the route declaration.
-rw-r--r-- | src/cuirass/http.scm | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/src/cuirass/http.scm b/src/cuirass/http.scm index 6f9eca5..bcd6217 100644 --- a/src/cuirass/http.scm +++ b/src/cuirass/http.scm @@ -362,20 +362,18 @@ Hydra format." (if hydra-build (respond-json (object->json-string hydra-build)) (respond-build-not-found id)))) - (('GET "build" build-id "details") - (let* ((id (string->number build-id)) - (build (and id (db-get-build id))) - (products (and build (db-get-build-products build-id)))) + (('GET "build" (= string->number id) "details") + (let* ((build (and id (db-get-build id))) + (products (and build (db-get-build-products id)))) (if build (respond-html - (html-page (string-append "Build " build-id) + (html-page (string-append "Build " id) (build-details build products) `(((#:name . ,(assq-ref build #:specification)) (#:link . ,(string-append "/jobset/" (assq-ref build #:specification))))))) - (respond-build-not-found build-id)))) - (('GET "build" build-id "log" "raw") - (let* ((id (string->number build-id)) - (build (and id (db-get-build id)))) + (respond-build-not-found id)))) + (('GET "build" (= string->number id) "log" "raw") + (let ((build (and id (db-get-build id)))) (if build (match (assq-ref build #:outputs) (((_ (#:path . (? string? output))) _ ...) @@ -388,13 +386,13 @@ Hydra format." #:headers `((location . ,uri))) #:body ""))) (() - ;; Not entry for BUILD-ID in the 'Outputs' table. + ;; Not entry for ID in the 'Outputs' table. (respond-json-with-error 500 - (format #f "Outputs of build ~a are unknown." build-id))) + (format #f "Outputs of build ~a are unknown." id))) (#f - (respond-build-not-found build-id))) - (respond-build-not-found build-id)))) + (respond-build-not-found id))) + (respond-build-not-found id)))) (('GET "output" id) (let ((output (db-get-output (string-append (%store-prefix) "/" id)))) |