mirror of
https://github.com/warmcat/libwebsockets.git
synced 2025-03-16 00:00:07 +01:00
![]() info.protocols works okay, but it has an annoying problem... you have to know the type for each protocol's pss at the top level of the code, so you can set the struct lws_protocols user_data size for it. Lws already rewrites the protocol tables for a vhost in the case of runtime protocol plugins... this adapts that already-existing code slightly to give a new optional way to declare the protocol array. Everything works as before by default, but now info.protocols may be NULL and info.pprotocols defined instead (if that's also NULL, as it will be if you just ignore it after memsetting to 0, then it continues to fall back to the dummy protocol handler as before). info.pprotocols is a NULL-termined array of pointers to lws_protocol structs. This can be composed at the top level of your code without knowing anything except the name of the externally-defined lws_protocol struct(s). The minimal example http-server-dynamic is changed to use the new scheme as an example. |
||
---|---|---|
.. | ||
mount-origin | ||
CMakeLists.txt | ||
localhost-100y.cert | ||
localhost-100y.key | ||
minimal-http-server-dynamic.c | ||
README.md |
lws minimal http server dynamic content
build
$ cmake . && make
usage
$ ./lws-minimal-http-server-dynamic
[2018/03/20 10:24:24:7099] USER: LWS minimal http server dynamic | visit http://localhost:7681
[2018/03/20 10:24:24:7099] NOTICE: Creating Vhost 'default' port 7681, 1 protocols, IPv6 off
Visit http://localhost:7681, which is all static content.
Click on the link to /dyn/anything, this opens a new tab with dynamicly-produced content.