libfast - FastCGI Application Server w/ Templates » History » Version 2
Martin Willi, 01.04.2008 09:46
1 | 1 | Martin Willi | |
---|---|---|---|
2 | 2 | Martin Willi | h1. libfast - [[FastCGI]] Application Server w/ Templates |
3 | 2 | Martin Willi | |
4 | 2 | Martin Willi | libfast is a small library built around libfcgi and ClearSilver. It wrapps these libraries properly and integrates session management and a MVC-like architecture. It targets embedded systems or servers where processing power and footprint is limited and should work with any [[FastCGI]] cappable webserver. |
5 | 2 | Martin Willi | |
6 | 2 | Martin Willi | |
7 | 2 | Martin Willi | h2. Architecture |
8 | 2 | Martin Willi | |
9 | 1 | Martin Willi | A web application based on libfast has a global and a session context: |
10 | 2 | Martin Willi | ** Global context |
11 | 2 | Martin Willi | **** inter-session data |
12 | 2 | Martin Willi | **** [browser:trunk/src/libstrongswan/database/database.h database connections] |
13 | 2 | Martin Willi | **** ... |
14 | 2 | Martin Willi | ** [browser:trunk/src/libfast/context.h Session context] |
15 | 2 | Martin Willi | **** per-session data |
16 | 2 | Martin Willi | **** [browser:trunk/src/libfast/controller.h controllers] |
17 | 2 | Martin Willi | **** [browser:trunk/src/libfast/filter.h filters] |
18 | 1 | Martin Willi | |
19 | 1 | Martin Willi | libfast automatically creates and manages a session for each connecting user and allocates a private session context. In that context, a defined set of controllers and filters are allocated. These instances are per session, so you might save session-specific data in them. |
20 | 1 | Martin Willi | |
21 | 1 | Martin Willi | The session context is synchronized, only one thread enters a session. The global context is accessed by all sessions, so you'll need to write global objects thread-save. |
22 | 1 | Martin Willi | |
23 | 1 | Martin Willi | |
24 | 2 | Martin Willi | h2. Building a web application |
25 | 2 | Martin Willi | |
26 | 2 | Martin Willi | |
27 | 1 | Martin Willi | Here a small example how to set up a web application: |
28 | 2 | Martin Willi | <pre> |
29 | 1 | Martin Willi | dispatcher_t *dispatcher; |
30 | 1 | Martin Willi | your_global_context_implementation_t *global; |
31 | 1 | Martin Willi | |
32 | 1 | Martin Willi | global = initialize_your_global_context(); |
33 | 1 | Martin Willi | |
34 | 1 | Martin Willi | dispatcher = dispatcher_create(NULL, FALSE, 180, |
35 | 1 | Martin Willi | (context_constructor_t)your_session_context_create, global); |
36 | 1 | Martin Willi | dispatcher->add_controller(dispatcher, your_controller1_create, param1); |
37 | 1 | Martin Willi | dispatcher->add_controller(dispatcher, your_controller2_create, param2); |
38 | 1 | Martin Willi | |
39 | 1 | Martin Willi | dispatcher->run(dispatcher, 20); |
40 | 1 | Martin Willi | dispatcher->waitsignal(dispatcher); |
41 | 1 | Martin Willi | |
42 | 1 | Martin Willi | dispatcher->destroy(dispatcher); |
43 | 1 | Martin Willi | global->destroy(); |
44 | 2 | Martin Willi | </pre> |
45 | 1 | Martin Willi | |
46 | 1 | Martin Willi | Have a look at the [browser:trunk/src/manager manager] for a more complete example. |