libfast - FastCGI Application Server w/ Templates » History » Version 1
Martin Willi, 01.04.2008 09:46
1 | 1 | Martin Willi | = libfast - FastCGI Application Server w/ Templates = |
---|---|---|---|
2 | 1 | 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. |
3 | 1 | Martin Willi | |
4 | 1 | Martin Willi | == Architecture == |
5 | 1 | Martin Willi | A web application based on libfast has a global and a session context: |
6 | 1 | Martin Willi | * Global context |
7 | 1 | Martin Willi | * inter-session data |
8 | 1 | Martin Willi | * [browser:trunk/src/libstrongswan/database/database.h database connections] |
9 | 1 | Martin Willi | * ... |
10 | 1 | Martin Willi | * [browser:trunk/src/libfast/context.h Session context] |
11 | 1 | Martin Willi | * per-session data |
12 | 1 | Martin Willi | * [browser:trunk/src/libfast/controller.h controllers] |
13 | 1 | Martin Willi | * [browser:trunk/src/libfast/filter.h filters] |
14 | 1 | Martin Willi | |
15 | 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. |
16 | 1 | Martin Willi | |
17 | 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. |
18 | 1 | Martin Willi | |
19 | 1 | Martin Willi | == Building a web application == |
20 | 1 | Martin Willi | |
21 | 1 | Martin Willi | Here a small example how to set up a web application: |
22 | 1 | Martin Willi | {{{ |
23 | 1 | Martin Willi | dispatcher_t *dispatcher; |
24 | 1 | Martin Willi | your_global_context_implementation_t *global; |
25 | 1 | Martin Willi | |
26 | 1 | Martin Willi | global = initialize_your_global_context(); |
27 | 1 | Martin Willi | |
28 | 1 | Martin Willi | dispatcher = dispatcher_create(NULL, FALSE, 180, |
29 | 1 | Martin Willi | (context_constructor_t)your_session_context_create, global); |
30 | 1 | Martin Willi | dispatcher->add_controller(dispatcher, your_controller1_create, param1); |
31 | 1 | Martin Willi | dispatcher->add_controller(dispatcher, your_controller2_create, param2); |
32 | 1 | Martin Willi | |
33 | 1 | Martin Willi | dispatcher->run(dispatcher, 20); |
34 | 1 | Martin Willi | dispatcher->waitsignal(dispatcher); |
35 | 1 | Martin Willi | |
36 | 1 | Martin Willi | dispatcher->destroy(dispatcher); |
37 | 1 | Martin Willi | global->destroy(); |
38 | 1 | Martin Willi | }}} |
39 | 1 | Martin Willi | |
40 | 1 | Martin Willi | Have a look at the [browser:trunk/src/manager manager] for a more complete example. |