libfast - FastCGI Application Server w/ Templates » History » Version 3
Tobias Brunner, 05.05.2009 19:27
trac conversion errors fixed
1 | 3 | Tobias Brunner | h1. libfast - FastCGI Application Server w/ Templates |
---|---|---|---|
2 | 1 | Martin Willi | |
3 | 3 | Tobias Brunner | libfast is a small library built around libfcgi and ClearSilver. It wraps 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 capable webserver. |
4 | 2 | Martin Willi | |
5 | 2 | Martin Willi | |
6 | 1 | Martin Willi | h2. Architecture |
7 | 2 | Martin Willi | |
8 | 1 | Martin Willi | A web application based on libfast has a global and a session context: |
9 | 3 | Tobias Brunner | * Global context |
10 | 3 | Tobias Brunner | ** inter-session data |
11 | 3 | Tobias Brunner | ** database connections (source:src/libstrongswan/database/database.h) |
12 | 3 | Tobias Brunner | ** ... |
13 | 3 | Tobias Brunner | * Session context (source:src/libfast/context.h) |
14 | 3 | Tobias Brunner | ** per-session data |
15 | 3 | Tobias Brunner | ** controllers (source:src/libfast/controller.h) |
16 | 3 | Tobias Brunner | ** filters (source:src/libfast/filter.h) |
17 | 1 | Martin Willi | |
18 | 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. |
19 | 1 | Martin Willi | |
20 | 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. |
21 | 1 | Martin Willi | |
22 | 1 | Martin Willi | |
23 | 2 | Martin Willi | h2. Building a web application |
24 | 2 | Martin Willi | |
25 | 2 | Martin Willi | |
26 | 1 | Martin Willi | Here a small example how to set up a web application: |
27 | 2 | Martin Willi | <pre> |
28 | 1 | Martin Willi | dispatcher_t *dispatcher; |
29 | 1 | Martin Willi | your_global_context_implementation_t *global; |
30 | 1 | Martin Willi | |
31 | 1 | Martin Willi | global = initialize_your_global_context(); |
32 | 1 | Martin Willi | |
33 | 1 | Martin Willi | dispatcher = dispatcher_create(NULL, FALSE, 180, |
34 | 1 | Martin Willi | (context_constructor_t)your_session_context_create, global); |
35 | 1 | Martin Willi | dispatcher->add_controller(dispatcher, your_controller1_create, param1); |
36 | 1 | Martin Willi | dispatcher->add_controller(dispatcher, your_controller2_create, param2); |
37 | 1 | Martin Willi | |
38 | 1 | Martin Willi | dispatcher->run(dispatcher, 20); |
39 | 1 | Martin Willi | dispatcher->waitsignal(dispatcher); |
40 | 1 | Martin Willi | |
41 | 1 | Martin Willi | dispatcher->destroy(dispatcher); |
42 | 1 | Martin Willi | global->destroy(); |
43 | 2 | Martin Willi | </pre> |
44 | 1 | Martin Willi | |
45 | 3 | Tobias Brunner | Have a look at the manager (source:src/manager) for a more complete example. |