[Libwebsockets] How to serve the mounts from the callback?

Andy Green andy at warmcat.com
Fri Jul 26 16:43:59 CEST 2019

On July 26, 2019 6:44:15 AM PDT, necktwi <necktwi at icloud.com> wrote:
>I want my http request to be handled by callback and after analyzing
>the request type then want to forward to the mount mechanism.

Instead of doing that, it's much better to partition your url space into a file mount for / and a dynamic mount at some specific base path, eg, /dyn


Lws can deal with this mount path  layering if you give the exceptions first and / as a catch-all.

>What is the source file for bin/libwebsockets-test-server? is it
>test-apps/test-server.c? I want to check how leaf.png is served; what
>source file should I've to check?

The test server used to do everything by hand, eg for leaf.jpg


This was a very high bar for people trying to learn the api.  It's all there but it's a big pile of everything.

At v3.0 and later, the minimal examples took over this teaching task.  The old test server was replaced with an implementation using plugins; the same plugins are used on the lwsws that runs libwebsockets.org.  eg


This is way cleaner and can still be used by including it at build-time, as well as a dynamically loaded plgin on lwsws.  And leaf.jpg is served by a mount.


>... Necktwi
>Libwebsockets mailing list
>Libwebsockets at ml.libwebsockets.org

More information about the Libwebsockets mailing list