gnunet-svn
[Top][All Lists]
Advanced

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

[gnunet-scheme] 35/49: examples/web: Allow module reloading.


From: gnunet
Subject: [gnunet-scheme] 35/49: examples/web: Allow module reloading.
Date: Sat, 25 Dec 2021 23:00:12 +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 fa0ded40dc303b3a5930800f956b4dde018278d1
Author: Maxime Devos <maximedevos@telenet.be>
AuthorDate: Tue Oct 5 09:15:49 2021 +0000

    examples/web: Allow module reloading.
    
    * examples/web.scm: Don't start the server if it's already started.
      (started?): New variable.
      (url-handler)[/reload]: New endpoint, reloading the examples/web.scm
      module.
---
 examples/web.scm | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/examples/web.scm b/examples/web.scm
index 7dba1a9..c100181 100644
--- a/examples/web.scm
+++ b/examples/web.scm
@@ -5,6 +5,10 @@
 ;; notice and this notice are preserved.  This file is offered as-is,
 ;; without any warranty.
 
+;; Go to localhost:8089/reload to reload the module
+(define-module (guile-user)
+  #:declarative? #f)
+
 (use-modules (fibers)
             (rnrs bytevectors)
             (gnu extractor enum)
@@ -103,6 +107,8 @@
            (decode (assoc-ref parameters "data-encoding")
                    (assoc-ref parameters "data"))))
 
+(define-once started? #f)
+
 (define (url-handler dht-server server request body)
   (match (uri-path (request-uri request))
     ("/" (respond/html
@@ -110,6 +116,9 @@
                (ul (li (a (@ (href "/network-size")) "network size"))
                    (li (a (@ (href "/search-dht")) "search the DHT")
                        (li (a (@ (href "/put-dht")) "add things to the 
DHT")))))))
+    ("/reload" ; TODO form with PUT request?
+     (reload-module (current-module))
+     (respond/html "reloaded!"))
     ("/network-size"
      (respond/html
       (let ((current-estimate (nse:estimate server)))
@@ -151,4 +160,6 @@
           (write-client impl server client response body)))))
     (loop)))
 
-(run-fibers (lambda () (start config)))
+(when (not started?)
+  (set! started? #t)
+  (run-fibers (lambda () (start config))))

-- 
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]