aboutsummaryrefslogtreecommitdiff
path: root/web/webserver.scm
diff options
context:
space:
mode:
authorPjotr Prins2023-08-07 11:28:00 +0200
committerPjotr Prins2023-08-07 11:28:00 +0200
commit9b9d22605d0581187809865f029541c0381cc164 (patch)
treea23226a61a11deace83f65dab46ed9cff5b79fa4 /web/webserver.scm
parentce73f0f544f33b6303c08fb39e02971bde77e1be (diff)
downloadgn-guile-9b9d22605d0581187809865f029541c0381cc164.tar.gz
Start on displaying HTML
Diffstat (limited to 'web/webserver.scm')
-rwxr-xr-xweb/webserver.scm11
1 files changed, 11 insertions, 0 deletions
diff --git a/web/webserver.scm b/web/webserver.scm
index c8c1fb2..e1a453c 100755
--- a/web/webserver.scm
+++ b/web/webserver.scm
@@ -193,10 +193,19 @@
(string-append "Resource X not found: "
(uri->string (request-uri request)))))
+(define (view-doc path page)
+ page)
+
(define (not-found uri)
(list (build-response #:code 404)
(string-append "Resource not found: " (uri->string uri))))
+(define* (render-doc path page #:key (extra-headers '()))
+ (list (append extra-headers
+ '((content-type . (text/html))))
+ (lambda (port)
+ (display (view-doc path page) port))))
+
(define (render-json json)
(list '((content-type . (application/json)))
(lambda (port)
@@ -215,6 +224,8 @@
(render-json info))
(('GET "version")
(render-json get-version))
+ (('GET "doc" path ... page) ; serve documents from /doc/
+ (render-doc path page))
(('GET "species.json")
(render-json (get-species-rec)))
(('GET "species.meta.json")