gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnunet-scheme] 39/49: examples/web: Dissect search result.


From: gnunet
Subject: [gnunet-scheme] 39/49: examples/web: Dissect search result.
Date: Sat, 25 Dec 2021 23:00:16 +0100

This is an automated email from the git hooks/post-receive script.

maxime-devos pushed a commit to branch master
in repository gnunet-scheme.

commit a2345b00ea800c5a10ac5e346bb6678adb061c15
Author: Maxime Devos <maximedevos@telenet.be>
AuthorDate: Tue Oct 5 22:33:26 2021 +0200

    examples/web: Dissect search result.
    
    * examples/web.scm
      (process-search-dht)[found]: Make a copy of slices.
      (process-search-dht): Make the HTML a definition list.
      (slice-copy): New procedure.
---
 examples/web.scm | 31 ++++++++++++++++++++++++++++---
 1 file changed, 28 insertions(+), 3 deletions(-)

diff --git a/examples/web.scm b/examples/web.scm
index 68b7083..e087a00 100644
--- a/examples/web.scm
+++ b/examples/web.scm
@@ -122,8 +122,13 @@
 (define (process-search-dht dht-server parameters)
   (define what)
   (define found? (make-condition))
-  (define (found . stuff)
-    (set! what stuff)
+  (define (found type key data expiration get-path put-path)
+    (set! what (list type
+                    (slice-copy key)
+                    (slice-copy data)
+                    expiration
+                    (slice-copy get-path)
+                    (slice-copy put-path)))
     (signal-condition! found?))
   (dht:start-get! dht-server
                  (string->number (assoc-ref parameters "type"))
@@ -135,10 +140,30 @@
   (wait found?)
   ;; TODO: properly format the result, streaming, stop searching
   ;; after something has been found or if the client closes the connection ...
-  (respond/html `(p "Found! " ,(object->string what))))
+  (respond/html `(div (p "Found! ")
+                     ;; TODO: better output, determine why the data is bogus
+                     (dl ,@(match what
+                             ((type key data expiration get-path put-path)
+                              `((dt "Type: ")
+                                (dd ,type)
+                                (dt "Key: ")
+                                (dd ,key)
+                                (dt "Data: ")
+                                (dd ,(object->string data))
+                                (dt "Expiration: ")
+                                (dd ,(object->string expiration))
+                                (dt "Get path: ") ; TODO as list
+                                (dd ,(object->string get-path))
+                                (dt "Put path: ")
+                                (dd ,(object->string put-path)))))))))
 
 (define-once started? #f)
 
+(define (slice-copy slice) ; TODO: move to (gnu gnunet utils bv-slice), use 
elsewhere?
+  (define s (make-slice/read-write (slice-length slice)))
+  (slice-copy! slice s)
+  s)
+
 (define (url-handler dht-server server request body)
   (match (uri-path (request-uri request))
     ("/" (respond/html

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]