guile-user
[Top][All Lists]
Advanced

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

Re: Streaming responses with Guile's web modules


From: Ludovic Courtès
Subject: Re: Streaming responses with Guile's web modules
Date: Sun, 23 Sep 2018 15:20:08 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux)

Hi Roel,

Roel Janssen <address@hidden> skribis:

> I'd like to implement a web server using the (web server) module, but
> allow for “streaming” results.  The way I image this would look like,
> is something like this:
>
> (define (request-handler request body)
>   (values '((content-type . (text/plain)))
>           ;; This function can build its response by writing to
>           ;; ‘port’, rather than to return the whole body as a
>           ;; string.
>           (lambda (port)
>             (format port "Hello world!"))))
>
> (run-server request-handler)
>
> Is this possible with the (web server) module?  If so, how?
> If not, what would be a good starting point to implement this?

As discussed on IRC a few days ago, this is not really possible.  ‘guix
publish’ works around it by providing a custom implementation of the
‘write’ method of the HTTP server and having handlers provide a “fake”
body to be interpreted by this ‘write’ implementation:

  https://git.savannah.gnu.org/cgit/guix.git/tree/guix/scripts/publish.scm#n690
  https://git.savannah.gnu.org/cgit/guix.git/tree/guix/scripts/publish.scm#n522

I reported this limitation of (web server) at
<https://issues.guix.info/issue/21093>.

Thanks,
Ludo’.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]