diff options
-rw-r--r-- | web/gn-uri.scm | 47 |
1 files changed, 18 insertions, 29 deletions
diff --git a/web/gn-uri.scm b/web/gn-uri.scm index b849e95..3455d51 100644 --- a/web/gn-uri.scm +++ b/web/gn-uri.scm @@ -3,11 +3,10 @@ #:use-module (ice-9 match) #:use-module (ice-9 regex) - #:export ( - get-version - ; url-parse-id - ; normalize-id - ; strip-lang + #:export (get-version + ;; url-parse-id + ;; normalize-id + ;; strip-lang mk-meta mk-data mk-doc @@ -18,50 +17,38 @@ mk-predicate prefix url-parse-id - normalize-id - )) - + normalize-id)) (define (normalize-id str) ;; (string-replace-substring (string-downcase str) " " "_") (match str (#f "unknown") - (_ (string-replace-substring str " " "_")) - )) + (_ (string-replace-substring str " " "_")))) (define (url-parse-id uri) (if uri - (car (reverse (string-split uri #\057))) - "unknown" - )) + (car (reverse (string-split uri #\/))) "unknown")) (define get-version "4.0.0") -; (define base-url -; "https://luna.genenetwork.org") - -;(define (prefix) -; "Build the API URL including version" -; (string-append base-url "/api/v" get-version)) - (define base-url "http://localhost:8091") -(define uri-base-url ; always points to genenetwork.org! +(define uri-base-url + ;always points to genenetwork.org! "http://genenetwork.org") (define (prefix) - "Build the API URL including version" - base-url) + "Build the API URL including version" base-url) -(define* (mk-url postfix #:optional (ext "")) +(define* (mk-url postfix + #:optional (ext "")) "Makes a fully qualified URL by adding the path (postfix+ext) to the API URL. If there is an existing http+hostname no prefix is added" (match (string-match "^http:" postfix) - [ #f (string-append (prefix) "/" postfix ext)] - [ _ (string-append postfix ext)] - )) + (#f (string-append (prefix) "/" postfix ext)) + (_ (string-append postfix ext)))) (define* (mk-uri postfix) "Add the path to the GN URI. A URI always points to http://genenetwork.org/" @@ -92,9 +79,11 @@ (define (mk-id postfix) "Expand URL to make $api/id/identifier. If postfix is a path it will only apply the last element" - (mk-url (string-append "id" "/" (url-parse-id postfix)))) + (mk-url (string-append "id" "/" + (url-parse-id postfix)))) (define (mk-gnid postfix) "Expand URL to make http://genenetwork.org/id/identifier. If postfix is a path it will only apply the last element" - (mk-uri (string-append "id" "/" (url-parse-id postfix)))) + (mk-uri (string-append "id" "/" + (url-parse-id postfix)))) |