From 3ff858a5fd78ee4b93af129149430bbd1b39a583 Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Sat, 24 Dec 2022 23:53:09 +0000 Subject: web: dev: Accept thunk to read project configuration. To the development server, pass a thunk to read project configuration instead of the project configuration itself. This allows us to hack on the project's tissue.scm without having to restart the development server to see changes. * bin/tissue (tissue-web-dev): Pass thunk to read project configuration instead of the project configuration itself. * tissue/web/dev.scm (handler, start-dev-web-server): Accept thunk to read project configuration instead of the project configuration itself. --- tissue/web/dev.scm | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'tissue') diff --git a/tissue/web/dev.scm b/tissue/web/dev.scm index 7f29be6..2be978c 100644 --- a/tissue/web/dev.scm +++ b/tissue/web/dev.scm @@ -32,11 +32,12 @@ #:use-module (tissue web static) #:export (start-dev-web-server)) -(define (handler request body xapian-index project) +(define (handler request body xapian-index project-thunk) "Handle web @var{request} with @var{body} and return two values---the response headers and body. See @code{start-dev-web-server} for -documentation of @var{xapian-index} and @var{project}." - (let ((path (uri-path (request-uri request)))) +documentation of @var{xapian-index} and @var{project-thunk}." + (let ((project (project-thunk)) + (path (uri-path (request-uri request)))) (log-request request) (cond ;; Search page @@ -63,17 +64,17 @@ documentation of @var{xapian-index} and @var{project}." (else (404-response request))))) -(define (start-dev-web-server port xapian-index project) +(define (start-dev-web-server port xapian-index project-thunk) "Start development web server listening on @var{port}. @var{xapian-index} is the path to the Xapian index to -search in. @var{project} is a @code{} object -describing the project." +search in. @var{project} is a thunk that returns a +@code{} object describing the project." (format (current-error-port) "Tissue development web server listening at http://localhost:~a~%" port) ;; Explicitly dereference the module and handler variable each time ;; so as to support live hacking. (run-server (cut (module-ref (resolve-module '(tissue web dev)) 'handler) - <> <> xapian-index project) + <> <> xapian-index project-thunk) 'http (list #:port port))) -- cgit v1.2.3