[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.
- [gnunet-scheme] 45/49: guix: Skip tests in guile-fibers/patched., (continued)
- [gnunet-scheme] 45/49: guix: Skip tests in guile-fibers/patched., gnunet, 2021/12/25
- [gnunet-scheme] 49/49: crypto: Fix type confusion in hash-slice [bugfix], gnunet, 2021/12/25
- [gnunet-scheme] 18/49: dht/client: Correct struct access when verifying messages., gnunet, 2021/12/25
- [gnunet-scheme] 26/49: examples/web.scm: Parse the answer to the DHT insertion form., gnunet, 2021/12/25
- [gnunet-scheme] 25/49: web/form: New module., gnunet, 2021/12/25
- [gnunet-scheme] 28/49: dht/client: Copy the key into the put message., gnunet, 2021/12/25
- [gnunet-scheme] 29/49: guix: Add guile-gcrypt., gnunet, 2021/12/25
- [gnunet-scheme] 44/49: guix: Skip tests in guile package., gnunet, 2021/12/25
- [gnunet-scheme] 37/49: examples/web: Correct destination of search form., gnunet, 2021/12/25
- [gnunet-scheme] 30/49: doc: Remove URLs., gnunet, 2021/12/25
- [gnunet-scheme] 39/49: examples/web: Dissect search result.,
gnunet <=
- [gnunet-scheme] 21/49: examples/web: Respond with HTML., gnunet, 2021/12/25
- [gnunet-scheme] 31/49: doc: Document dependency on Guile-Gcrypt., gnunet, 2021/12/25
- [gnunet-scheme] 41/49: dht/client: Impose some bounds on the replication level., gnunet, 2021/12/25
- [gnunet-scheme] 36/49: examples/web: License as AGPL., gnunet, 2021/12/25
- [gnunet-scheme] 42/49: dht/client: Resolve race condition., gnunet, 2021/12/25
- [gnunet-scheme] 48/49: examples/web (search-dht): Fail gracefully in case of invalid input, gnunet, 2021/12/25