diff options
Diffstat (limited to 'gn3-guile')
-rwxr-xr-x | gn3-guile/web/webserver.scm | 19 |
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) |