[Libwebsockets] Maintenance of get_mimetype(const char *file)

Andy Green andy at warmcat.com
Thu Dec 1 20:58:56 CET 2016



On December 1, 2016 8:33:54 PM GMT+08:00, Shmuel Weiss <sweiss at kramerel.com> wrote:
>Hi All,
>
>Do you have a get_mimetype with all the types supported ?
>
>Every time our web team is adding a new file I have to add its suffix
>in the function and it is really annoying.
>How to you deal with this in your applications ?

In v2.1+, you can add your own per-mount mimetype mappings from user code.  These then work in addition to the canned list.

In lwsws it's just like this in the mount definition in the config JSON

 "extra-mimetypes": { ".zip": "application/zip", ".doc": "text/evil" } 

In code, you set the member .extra_mimetypes in struct lws_http_mount to point to a linked-list of struct lws_protocol_vhost_options, where .name is the ".suffix" and .value is the mimetype.

test-server-v2.0.c shows some similar examples of how to make a linked-list of structs.

-Andy

>Thanks.
>
>Sam.
>
>
>
>------------------------------------------------------------------------
>
>_______________________________________________
>Libwebsockets mailing list
>Libwebsockets at ml.libwebsockets.org
>http://libwebsockets.org/mailman/listinfo/libwebsockets




More information about the Libwebsockets mailing list