On 12/20/2015 09:03 PM, Roberto De Ioris wrote:
>> Hi ...
>>
>> I have tried to play a bit more with uwsgi, and have made a simple and
>> well working C++11 (std::function) interface what is able to build using
>> CMake.
>>
>> This works well, and I now can see how the threads are working (like I
>> hoped and expected). See
>> https://github.com/druppy/spikes/blob/master/cpp/uwsgi/test_handler.cpp
>> :-)
>>
>> Now in order to move as much code as possible to uwsgi config (as
>> recommended) , I really like to be able to use the mount / apps idea,
>> but I am a bit lost as to how to do this.
>>
>> There is this :
>>
>>    struct uwsgi_app *uwsgi_add_app(int, uint8_t, char *, int, void *,
>> void *);
>>
>> in the header file, but I really like to know what the argument are, and
>> if I need to do something to returning structure in order to make the
>> app ready.
>>
>> I know this it originally written to support python, but this is so
>> tempting to try use in C++ :-)
>>
>> Thanks for a really nice project, I will try to use in more and more
>> places as it adds much flexibility to my production systems.
>>
>> Kind regards
>>
> the first int field is the application id (a simple number).
>
> You can get the first available app_id using the uwsgi_apps_cnt macro.
>
> The second uint8_t is the modifier1.
>
> Then you have a char * and a int thatyou can use as the mount point (like
> "/foobar", 7 ).
>
> The last two fields are for your specific needs. Every plugin makes a
> different use of them. You can (as an example) store the function pointer
> of the code to call for every mountpoint and so on:
>
> // example from the psgi plugin
> int id = uwsgi_apps_cnt;
> struct uwsgi_app *wi = uwsgi_add_app(id, psgi_plugin.modifier1, "/foo", 4,
> interpreters, callables);
>
Thanks for you precise answer, that all makes sense ... the two last
void pointers are just pointers, the uwsgi only pass along on the
uwsgi_app structure, This is a nice place for a "this" pointer :-)

I am a bit confused about the syntax in config, If I have a module
called cpptest and two apps called "/app1" and "/app2" (do i need the
/), would the syntax in the config look something like this ?

mount=/app1=cpptest:/app1
mount=/app2=cpptest:/app2

I guess uwsgi owns the uwsgi_app structure that is returned, but how is
the live circle of the app ? will i need to re-register the apps under
any conditions, and when will it be safe to register, in the uwsgi init
function ?

Also, there are 2 callbacks ...

void *(*request_subhandler) (struct wsgi_request *, struct uwsgi_app *);
int (*response_subhandler) (struct wsgi_request *);

I quess that I need to set the first to my callback, but what is the
second for ?

Sorry for all the questions ...

/BL

_______________________________________________
uWSGI mailing list
[email protected]
http://lists.unbit.it/cgi-bin/mailman/listinfo/uwsgi

Reply via email to