Update README.md

This commit is contained in:
Alex Hultman
2018-06-20 22:31:16 +02:00
committed by GitHub
parent 73aa9cae6b
commit fc0084cdc4
+4 -3
View File
@@ -10,15 +10,16 @@ v0.15 is a complete rewrite of µWS using µSockets as foundation. This leads to
#### Streams and helpers
HttpSockets are proper streams in v0.15 and do scale for large sends as well as for small ones. "Streams" are in/out per-socket-callbacks for giving or storing streamed data.
```c++
uWS::defaultHub.onHttpRequest([buffer](HttpSocket *s, HttpRequest *req) {
// Seamless swapping between SSL / non-SSL by using uWS::Context() instead!
uWS::SSLContext(options).onHttpRequest([buffer](auto *s, HttpRequest *req) {
if (req->getUrl() == "/") {
s->writeStatus(200)->writeHeader("Server", "µWebSockets v0.15")->end(buffer, 512);
s->writeStatus(200)->writeHeader("Hello", "World")->end(buffer, 512);
} else {
std::cout << "Got HTTP request at URL: " << req->getUrl() << std::endl;
}
}).listen("localhost", 3000, 0).run();
}).listen("localhost", 3000, 0);
```
#### HTTP router helpers