HTTP Session¶
udho server takes a LoggerT and a CacheT as template parameters. The LoggerT provides logging facilities and the CacheT serves as the HTTP session. the first parameter udho::bridge bridges a server with the contexts. It provides utilities like document root, that are configured at the server to the callable’s context. The reference to the bridge can be accessed through aux() method in the context.
typedef server<udho::bridge, LoggerT, CacheT> server_type;
The cache is implemented by the template udho::cache::store<KeyT, States...>. The cache::store serves as a key-value store where the set of possible values are limited by the variadic parameter States....
struct X{};
struct Y{};
struct Z{};
udho::cache::store<int, X, X, Z> store;
In the example above an integer indexed store is created that can store only three types of values (X, Y, Z) for each key. Any read or write opration using any type other than these three will be restricted at compile time. The operations that can be performed on the store are
checks for existance of any value of type
Vagainst thekeygets the value of type
Vassociated with thekey. If no such value is inserted returns thedefault_valuereturns the value of type
Vassociated withkeyand throws exception if that doesn’t exist.associates a value of type
Vwithkey
udho uses boost::uuids::uuid as KeyTto provide session id. So each session id is 128 bit uuid generated by boost uuid library.