rikitiki
v0.1.67
Build C++ web server modules that allow easy routing and deployment.
|
The basic idea behind rikitiki is that each module that can push some information to a webpage should just be a collection of handlers. Modules are simply structs with a Register function:
will define a functional, albeit useless, module.
To make it functional, we need to add handlers. Most of the time, you want to add routes, which you can do like so:
This will create three entry points for your site. When called, they will simply display the text streamed to the ConnContext object.
A module on it's own, even with entry points, is still a little useless – to make it run we have to incorporate it into either an apache module or create an executable for it on top of mongoose. Neither is particularly hard to do.
We can instantiate and run a mongoose server against a module with:
Running this executable will start a server on port 5000. Test each entry point with:
Running the module in apache is more involved, but not by much. A macro does most of the code set-up for us:
when compiled to a shared object, this will expose a 'helloWorld_module' to apache. Supposing we compiled a 'mod_helloWorld.so' shared object, we need to take that file and copy or link it to apaches modules directory. On most linux systems, that is going to be /etc/httpd/modules.
Then we need to add the following line to the httpd.conf file (usually at /etc/httpd/conf/httpd.conf on linux systems):
or
for windows.
Run or restart apache, and the module should be loaded and available:
Clearly though, these addresses are dependent on the particular apache configuration.