aboutsummaryrefslogtreecommitdiff
path: root/web
diff options
context:
space:
mode:
authorPjotr Prins2023-08-23 11:13:43 +0200
committerPjotr Prins2023-08-23 11:13:43 +0200
commitc322b6e5f5011d42a657334553ce0698c567ac2c (patch)
tree93c0caf1f94c4db7103eacd11a47f0ce5a5a564b /web
parentd2e12c6e3cd695dee4aed39e481fd8c18424b278 (diff)
downloadgn-guile-c322b6e5f5011d42a657334553ce0698c567ac2c.tar.gz
Refactoring URIs
Diffstat (limited to 'web')
-rw-r--r--web/gn-uri.scm36
1 files changed, 21 insertions, 15 deletions
diff --git a/web/gn-uri.scm b/web/gn-uri.scm
index 951b24d..de70ea7 100644
--- a/web/gn-uri.scm
+++ b/web/gn-uri.scm
@@ -1,5 +1,7 @@
(define-module (web gn-uri)
#:use-module (ice-9 string-fun)
+ #:use-module (ice-9 match)
+ #:use-module (ice-9 regex)
#:export (
get-version
@@ -36,37 +38,41 @@
(define get-version
"2.0")
-; (define (base-url)
+; (define base-url
; "https://luna.genenetwork.org")
;(define (prefix)
; "Build the API URL including version"
-; (string-append (base-url) "/api/v" get-version))
+; (string-append base-url "/api/v" get-version))
-(define (base-url)
+(define base-url
"http://localhost:8091")
-(define uri-base-url
+(define uri-base-url ; always points to genenetwork.org!
"http://genenetwork.org")
(define (prefix)
"Build the API URL including version"
- (base-url))
+ base-url)
(define* (mk-url postfix #:optional (ext ""))
- "Add the path to the API URL"
- (string-append (prefix) "/" postfix 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)]
+ ))
(define* (mk-uri postfix)
- "Add the path to the GN URI"
+ "Add the path to the GN URI. A URI always points to http://genenetwork.org/"
(string-append uri-base-url "/" postfix))
(define (mk-html path)
- "Create a pointer to HTML documentation"
- (string-append (base-url) "/" path ".html"))
+ "Create a pointer to API HTML documentation"
+ (mk-url path ".html"))
(define (mk-doc path)
- "Create a pointer to HTML documentation"
+ "Create a pointer to API HTML documentation (doc infix)"
(mk-html (string-append "doc/" path)))
(define (mk-meta path)
@@ -74,12 +80,15 @@
(mk-url path ".meta.json"))
(define (mk-data path)
- "Create a JSON URL for the API path"
+ "Append .json for the API path. If it is not a full URL it will prepend the host"
(mk-url path ".json"))
(define (mk-term postfix)
(mk-html (string-append "term" "/" postfix)))
+(define (mk-predicate postfix)
+ (mk-html (string-append "predicate" "/" postfix)))
+
(define (mk-id postfix)
"Expand URL to make $api/id/identifier.
If postfix is a path it will only apply the last element"
@@ -89,6 +98,3 @@
"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))))
-
-(define (mk-predicate postfix)
- (mk-html (string-append "predicate" "/" postfix)))