diff options
author | Christopher Baines <mail@cbaines.net> | 2020-04-09 22:33:17 +0100 |
---|---|---|
committer | Christopher Baines <mail@cbaines.net> | 2020-04-10 20:34:47 +0100 |
commit | e7a9fa03988d8e866478162c0afab5020475405d (patch) | |
tree | db4ea806b41b66676e599c0369be5547018457a4 | |
parent | 89a47de2fb202560b4872be5b48119d5fdc9a733 (diff) | |
download | build-coordinator-e7a9fa03988d8e866478162c0afab5020475405d.tar build-coordinator-e7a9fa03988d8e866478162c0afab5020475405d.tar.gz |
Implement more of the /agent/UUID GET behaviour
-rw-r--r-- | guix-build-coordinator/agent-messaging/http.scm | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/guix-build-coordinator/agent-messaging/http.scm b/guix-build-coordinator/agent-messaging/http.scm index d070ac1..0376a55 100644 --- a/guix-build-coordinator/agent-messaging/http.scm +++ b/guix-build-coordinator/agent-messaging/http.scm @@ -27,6 +27,7 @@ #:use-module (web request) #:use-module (web response) #:use-module (web uri) + #:use-module (guix-build-coordinator datastore) #:export (http-agent-messaging-start-server)) (define (http-agent-messaging-start-server port host secret-key-base @@ -44,7 +45,8 @@ (split-and-decode-uri-path (uri-path (request-uri request)))) body - secret-key-base))) + secret-key-base + datastore))) #:host host #:port port)) #:on-error 'backtrace @@ -78,12 +80,20 @@ port. Also, the port used can be changed by passing the --port option.\n" (define (controller request method-and-path-components body - secret-key-base) + secret-key-base + datastore) (define (controller-thunk) (match method-and-path-components (('GET "agent" uuid) - (render-json - `((agent . ,uuid)))) + (let ((agent (datastore-find-agent datastore uuid))) + (if agent + (render-json + `((agent . ,uuid) + ,@agent)) + (render-json + (simple-format #f "no agent found with id: ~A" + uuid) + #:code 404)))) (('PATCH "agent" uuid) (no-content)) (_ |