diff options
author | Pjotr Prins | 2023-08-18 15:41:28 +0200 |
---|---|---|
committer | Pjotr Prins | 2023-08-18 15:41:28 +0200 |
commit | afd3d25530401569a5953dc1c411f43a56ebd02c (patch) | |
tree | 95188317effce4e1b90e898b1d4f582cb033c848 /web/gn-uri.scm | |
parent | b9fb2c69136fe243fc9c6f7c3c4f8917814a401e (diff) | |
download | gn-guile-afd3d25530401569a5953dc1c411f43a56ebd02c.tar.gz |
Adding test infrastructure and reorganizing modules - still not happy with (web uri)
Diffstat (limited to 'web/gn-uri.scm')
-rw-r--r-- | web/gn-uri.scm | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/web/gn-uri.scm b/web/gn-uri.scm new file mode 100644 index 0000000..a4292f0 --- /dev/null +++ b/web/gn-uri.scm @@ -0,0 +1,75 @@ +(define-module (web gn-uri) + #:use-module (ice-9 string-fun) + + #:export ( + get-version + ; url-parse-id + ; normalize-id + ; strip-lang + mk-meta + mk-data + mk-doc + prefix + url-parse-id + normalize-id + )) + + + +(define (normalize-id str) + ;; (string-replace-substring (string-downcase str) " " "_") + (string-replace-substring str " " "_") + ) + +(define (url-parse-id uri) + (if uri + (car (reverse (string-split uri #\057))) + "unknown" + )) + + +(define get-version + "2.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 (prefix) + "Build the API URL including version" + (base-url)) + +(define* (mk-url postfix #:optional (ext "")) + "Add the path to the API URL" + (string-append (prefix) "/" postfix ext)) + +(define (mk-html path) + "Create a pointer to HTML documentation" + (string-append (base-url) "/" path ".html")) + +(define (mk-doc path) + "Create a pointer to HTML documentation" + (mk-html (string-append "doc/" path))) + +(define (mk-meta path) + "Create a meta URL for the API path" + (mk-url path ".meta.json")) + +(define (mk-data path) + "Create a JSON URL for the API path" + (mk-url path ".json")) + +(define (mk-term postfix) + (mk-html (string-append "term" "/" postfix))) + +(define (mk-id postfix) + (mk-html (string-append "id" "/" postfix))) + +(define (mk-predicate postfix) + (mk-html (string-append "predicate" "/" postfix))) |