diff options
author | Pjotr Prins | 2023-07-17 12:18:12 +0200 |
---|---|---|
committer | Pjotr Prins | 2023-07-17 12:18:12 +0200 |
commit | 428f6eab3e9fbd177f0dc59857ba9ba9c87548a6 (patch) | |
tree | d4e602b7fb6bb8f8f316f8ec06ff310960459be2 | |
parent | 69acd15a9748a22f4cb14fe566226f39ac197c6a (diff) | |
download | genenetwork3-428f6eab3e9fbd177f0dc59857ba9ba9c87548a6.tar.gz |
refactoring
-rwxr-xr-x | gn3-guile/web/webserver.scm | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/gn3-guile/web/webserver.scm b/gn3-guile/web/webserver.scm index b6f3417..0803018 100755 --- a/gn3-guile/web/webserver.scm +++ b/gn3-guile/web/webserver.scm @@ -60,16 +60,13 @@ (,(mk-url "datasets")."Get a list of datasets"))))) -(define (sparql-scm query) - (json-string->scm - (bytevector->string (receive (response-status response-body) +(define (sparql-exec query) + "Execute raw SPARQL query returning a json object" + (bytevector->string (receive (response-status response-body) (http-request (string-append "https://sparql.genenetwork.org/sparql?default-graph-uri=&query=" (uri-encode query) "&format=application%2Fsparql-results%2Bjson")) response-body) "UTF-8" - ))) - -(define (sparql-exec query) - (sparql-scm query)) + )) (define (sparql-names response) (cdr (assoc "vars" (cdr (assoc "head" response)))) @@ -79,6 +76,13 @@ (cdr (assoc "bindings" (cdr (assoc "results" response ))))) +(define (sparql-scm query) + "Return dual S-exp" + (let response (((json-string->scm (sparql-exec query))) + (values (sparql-names response) (sparql-results response)) + ))) + + (define (sparql-exec query) "Return list of varnames and list of results" (let ([response (sparql-scm query)]) |