aboutsummaryrefslogtreecommitdiff
path: root/gn3-guile
diff options
context:
space:
mode:
authorPjotr Prins2023-07-12 04:49:18 -0500
committerPjotr Prins2023-07-12 04:49:18 -0500
commitaf02ec582494b52390f5c2d974f8700f39adcf2a (patch)
tree0a2fef87e5edf7fde1bbf4b318a179e66065c277 /gn3-guile
parent661a9748147d60068d38a2a40e53131447548008 (diff)
downloadgenenetwork3-af02ec582494b52390f5c2d974f8700f39adcf2a.tar.gz
Handle multi-value
Diffstat (limited to 'gn3-guile')
-rwxr-xr-xgn3-guile/web/webserver.scm19
1 files changed, 17 insertions, 2 deletions
diff --git a/gn3-guile/web/webserver.scm b/gn3-guile/web/webserver.scm
index 71ad79c..d7687a0 100755
--- a/gn3-guile/web/webserver.scm
+++ b/gn3-guile/web/webserver.scm
@@ -79,6 +79,12 @@
(cdr (assoc "bindings" (cdr (assoc "results" response
)))))
+(define (sparql-exec query)
+ "Return list of varnames and list of results"
+ (let ([response (sparql-scm query)])
+ (values (sparql-names response) (sparql-results response))
+ ))
+
(define (sparql-species)
(sparql-exec "
PREFIX gn: <http://genenetwork.org/>
@@ -107,6 +113,10 @@ SELECT DISTINCT ?species ?p ?o WHERE {
(define (get-species-all)
(sparql-species-meta))
+(define (get-species)
+ (receive (names results) (sparql-species))
+ results)
+
(define (triples)
(array->list (get-species-all)))
@@ -118,11 +128,15 @@ SELECT DISTINCT ?species ?p ?o WHERE {
;; ---- REST API web server handler
-(define (not-found request)
+(define (not-found2 request)
(values (build-response #:code 404)
- (string-append "Resource not found: "
+ (string-append "Resource X not found: "
(uri->string (request-uri request)))))
+(define (not-found uri)
+ (list (build-response #:code 404)
+ (string-append "Resource not found: " (uri->string uri))))
+
(define (render-json json)
(list '((content-type . (application/json)))
(lambda (port)
@@ -140,6 +154,7 @@ SELECT DISTINCT ?species ?p ?o WHERE {
(render-json (get-species)))
(('GET "species-all")
(render-json (triples)))
+ (_ (not-found (request-uri request)))
))
(define (request-path-components request)