summary refs log tree commit diff
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2017-04-19 23:39:27 +0200
committerLudovic Courtès <ludo@gnu.org>2017-04-19 23:43:51 +0200
commite1bbc0e38d0c9a5d248ec8b686fdd0a972a61ff4 (patch)
tree4acedf6fb8bf60c1cdbf5348cdb6d08b24d6edc3
parent63422bbb0a874b74fd0462e5c44b11f10669ef8d (diff)
downloadguix-e1bbc0e38d0c9a5d248ec8b686fdd0a972a61ff4.tar.gz
publish: Add a handler for / and /index.html.
Suggested by Quiliro <quiliro@riseup.net>
in <https://bugs.gnu.org/26567>.

* guix/scripts/publish.scm (render-home-page): New procedure.
(make-request-handler): Handle it.
-rw-r--r--guix/scripts/publish.scm20
1 files changed, 20 insertions, 0 deletions
diff --git a/guix/scripts/publish.scm b/guix/scripts/publish.scm
index 9dc006e7ab..3faff061a7 100644
--- a/guix/scripts/publish.scm
+++ b/guix/scripts/publish.scm
@@ -39,6 +39,7 @@
   #:use-module (web response)
   #:use-module (web server)
   #:use-module (web uri)
+  #:autoload   (sxml simple) (sxml->xml)
   #:use-module (guix base32)
   #:use-module (guix base64)
   #:use-module (guix config)
@@ -532,6 +533,22 @@ has the given HASH of type ALGO."
             (not-found request)))
       (not-found request)))
 
+(define (render-home-page request)
+  "Render the home page."
+  (values `((content-type . (text/html (charset . "UTF-8"))))
+          (call-with-output-string
+            (lambda (port)
+              (sxml->xml '(html
+                           (head (title "GNU Guix Substitute Server"))
+                           (body
+                            (h1 "GNU Guix Substitute Server")
+                            (p "Hi, "
+                               (a (@ (href
+                                      "https://gnu.org/s/guix/manual/html_node/Invoking-guix-publish.html"))
+                                  (tt "guix publish"))
+                               " speaking.  Welcome!")))
+                         port)))))
+
 (define extract-narinfo-hash
   (let ((regexp (make-regexp "^([a-df-np-sv-z0-9]{32}).narinfo$")))
     (lambda (str)
@@ -686,6 +703,9 @@ blocking."
           ;; /nix-cache-info
           (("nix-cache-info")
            (render-nix-cache-info))
+          ;; /
+          ((or () ("index.html"))
+           (render-home-page request))
           ;; /<hash>.narinfo
           (((= extract-narinfo-hash (? string? hash)))
            ;; TODO: Register roots for HASH that will somehow remain for