about summary refs log tree commit diff stats
path: root/rnd/guile/play.scm
diff options
context:
space:
mode:
authorelioat <elioat@tilde.institute>2022-12-04 15:16:52 -0500
committerelioat <elioat@tilde.institute>2022-12-04 15:16:52 -0500
commit5831542e01209729390f5171d54f505b133ab47e (patch)
tree188391d6e89393849d5b6f53cfb5ca6d994536f5 /rnd/guile/play.scm
parent8f83e6377a7a5e4209f8996c1c9e6870f8ec66b5 (diff)
downloaddecember-2022-5831542e01209729390f5171d54f505b133ab47e.tar.gz
re-org of rnd
Diffstat (limited to 'rnd/guile/play.scm')
-rw-r--r--rnd/guile/play.scm24
1 files changed, 24 insertions, 0 deletions
diff --git a/rnd/guile/play.scm b/rnd/guile/play.scm
new file mode 100644
index 0000000..92d5538
--- /dev/null
+++ b/rnd/guile/play.scm
@@ -0,0 +1,24 @@
+;;; Hello HTTP server
+(use-modules 
+  (web server)
+  (web request)
+  (web response)
+  (web uri))
+
+(define (request-path-components request)
+  (split-and-decode-uri-path (uri-path (request-uri request))))
+
+(define (hello-handler request body)
+  (if (equal? (request-path-components request)
+              '("banana"))
+      (values '((content-type . (text/plain)))
+              "banana kiwi apple pineapple watermelon grapefruit")
+      (not-found request)))
+
+(define (not-found request)
+  (values (build-response #:code 404)
+          (string-append "Resource not found: "
+                         (uri->string (request-uri request)))))
+
+
+(run-server hello-handler)