mirror of
https://github.com/vale981/lack
synced 2025-03-04 17:01:41 -05:00
Mention Lack.Util.Writer-Stream in README.
This commit is contained in:
parent
8c6ba6f41d
commit
c8b6b003d4
1 changed files with 16 additions and 0 deletions
16
README.md
16
README.md
|
@ -117,6 +117,22 @@ An application may omit the third element (the body) when calling the responder.
|
|||
while chunk))))
|
||||
```
|
||||
|
||||
In case of that you would prefer a stream to a function, `lack.util.writer-stream` wraps the function and allows you to treat it as a stream:
|
||||
|
||||
```common-lisp
|
||||
(import 'lack.util.writer-stream:make-writer-stream)
|
||||
|
||||
(lambda (env)
|
||||
(lambda (responder)
|
||||
(let* ((writer (funcall responder '(200 (:content-type "application/json"))))
|
||||
(stream (make-writer-function writer)))
|
||||
(loop for chunk = (fetch-something)
|
||||
do (write-sequence chunk stream)
|
||||
while chunk
|
||||
finally
|
||||
(finish-output stream)))))
|
||||
```
|
||||
|
||||
This delayed response and streaming API is useful if you want to implement a non-blocking I/O based server streaming or long-poll Comet push technology.
|
||||
|
||||
## Middlewares
|
||||
|
|
Loading…
Add table
Reference in a new issue