[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnunet-scheme] 38/49: examples/web: Implement searching form.
From: |
gnunet |
Subject: |
[gnunet-scheme] 38/49: examples/web: Implement searching form. |
Date: |
Sat, 25 Dec 2021 23:00:15 +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 128a9765217561dcc2a75bebd1f5d452dde54d6c
Author: Maxime Devos <maximedevos@telenet.be>
AuthorDate: Tue Oct 5 09:40:28 2021 +0000
examples/web: Implement searching form.
* examples/web.scm
(search-form)[method]: Change to "post" for now.
(process-search-dht): New procedure.
(url-handler)[/search-dht]: Call 'process-search-dht' if there is a body.
---
examples/web.scm | 26 ++++++++++++++++++++++++--
1 file changed, 24 insertions(+), 2 deletions(-)
diff --git a/examples/web.scm b/examples/web.scm
index 01b47f0..68b7083 100644
--- a/examples/web.scm
+++ b/examples/web.scm
@@ -21,6 +21,7 @@
#:declarative? #f)
(use-modules (fibers)
+ (fibers conditions)
(rnrs bytevectors)
(gnu extractor enum)
(gnu gnunet block)
@@ -78,7 +79,7 @@
(define search-form
`(form
- (@ (action "/search-dht") (method "get"))
+ (@ (action "/search-dht") (method "post")) ; TODO should be "get"
(ul ,@(common-get/put-form-parts "get-"))
(input (@ (type "submit") (value "Search the DHT")))))
@@ -118,6 +119,24 @@
(decode (assoc-ref parameters "data-encoding")
(assoc-ref parameters "data"))))
+(define (process-search-dht dht-server parameters)
+ (define what)
+ (define found? (make-condition))
+ (define (found . stuff)
+ (set! what stuff)
+ (signal-condition! found?))
+ (dht:start-get! dht-server
+ (string->number (assoc-ref parameters "type"))
+ (decode (assoc-ref parameters "key-encoding")
+ (assoc-ref parameters "key"))
+ found
+ #:desired-replication-level
+ (string->number (assoc-ref parameters "replication-level")))
+ (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))))
+
(define-once started? #f)
(define (url-handler dht-server server request body)
@@ -136,7 +155,10 @@
(if current-estimate
(estimate->html current-estimate)
'(p "No etimate yet")))))
- ("/search-dht" (respond/html search-form))
+ ("/search-dht" ; TODO check method and Content-Type, validation ...
+ (if (pk 'b body)
+ (process-search-dht dht-server (urlencoded->alist body))
+ (respond/html search-form)))
("/put-dht" ; TODO check method and Content-Type, validation ...
(if body
(begin
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [gnunet-scheme] 40/49: examples/web: Don't hash the data., (continued)
- [gnunet-scheme] 40/49: examples/web: Don't hash the data., gnunet, 2021/12/25
- [gnunet-scheme] 35/49: examples/web: Allow module reloading., gnunet, 2021/12/25
- [gnunet-scheme] 23/49: examles/web: Add a non-functional form for DHT insertions., gnunet, 2021/12/25
- [gnunet-scheme] 15/49: Update copyright notices, gnunet, 2021/12/25
- [gnunet-scheme] 34/49: crypto: Implement functional variants., gnunet, 2021/12/25
- [gnunet-scheme] 33/49: examples/web: Hash free-form text first., gnunet, 2021/12/25
- [gnunet-scheme] 46/49: Merge branch 'dht'., gnunet, 2021/12/25
- [gnunet-scheme] 11/49: config: Define default UNIXPATH for DHT service., gnunet, 2021/12/25
- [gnunet-scheme] 16/49: Merge branch 'master' into dht, gnunet, 2021/12/25
- [gnunet-scheme] 19/49: dht/client: Recognise client result messages., gnunet, 2021/12/25
- [gnunet-scheme] 38/49: examples/web: Implement searching form.,
gnunet <=
- [gnunet-scheme] 43/49: examples/web: Display UTF-8 keys and data as text., gnunet, 2021/12/25
- [gnunet-scheme] 32/49: crypto: Implement a wrapper for hashing with bytevector slices., gnunet, 2021/12/25
- [gnunet-scheme] 47/49: web: Extract HTTP implementation from Cuirass., gnunet, 2021/12/25
- [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