Initial streams support

This commit is contained in:
Alex Hultman
2018-06-24 01:47:58 +02:00
parent 0cbccaf08e
commit 377d1b3ee0
6 changed files with 90 additions and 70 deletions
+9 -1
View File
@@ -22,7 +22,15 @@ int main() {
app.onGet("/", [](auto *s, auto *req, auto *args) {
s->writeStatus("200 OK")->writeHeader("Hello", "World")->end(buffer);
// this one is simple and okay for small sends
/*s->writeStatus("200 OK")
->writeHeader("Server", "uWebSockets")
->end(buffer);*/
// for large sends you want a stream!
s->writeStatus("200 OK")->write([](int offset) {
return std::string_view(buffer.data() + offset, buffer.length() - offset);
}, buffer.length());
}).onWebSocket("/wsApi", []() {