Project

General

Profile

libfast - FastCGI Application Server w/ Templates » History » Version 2

Version 1 (Martin Willi, 01.04.2008 09:46) → Version 2/3 (Martin Willi, 01.04.2008 09:46)


h1.
= libfast - [[FastCGI]] FastCGI Application Server w/ Templates

=
libfast is a small library built around libfcgi and ClearSilver. !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]] FastCGI cappable webserver.

h2.


==
Architecture

==
A web application based on libfast has a global and a session context:
**

*
Global context
****

*
inter-session data
****

*
[browser:trunk/src/libstrongswan/database/database.h database connections]
****

*
...
**

*
[browser:trunk/src/libfast/context.h Session context]
****

*
per-session data
****

*
[browser:trunk/src/libfast/controller.h controllers]
****

*
[browser:trunk/src/libfast/filter.h filters]

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.

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.

h2.


==
Building a web application

==

Here a small example how to set up a web application:
<pre>
{{{
dispatcher_t *dispatcher;
your_global_context_implementation_t *global;

global = initialize_your_global_context();

dispatcher = dispatcher_create(NULL, FALSE, 180,
(context_constructor_t)your_session_context_create, global);
dispatcher->add_controller(dispatcher, your_controller1_create, param1);
dispatcher->add_controller(dispatcher, your_controller2_create, param2);

dispatcher->run(dispatcher, 20);
dispatcher->waitsignal(dispatcher);

dispatcher->destroy(dispatcher);
global->destroy();
</pre>

}}}

Have a look at the [browser:trunk/src/manager manager] for a more complete example.