For any specific question (not convenient for an issue): matthieu.moinvaziri@epitech.eu
openZia is a C++ 17 cross-platform API for the 3rd year Epitech project Zia.
This library is intended to be used to build a robust and modular HTTP server.
This API was designed with a strict philosophy guideline :
Rigor > Maintenability > Efficiency > Simplicity
Thus, openZia will exploit the best of C++ language, avoiding risky design patterns and opting for best practises.
You still don't understand why you should use openZia but you want the best for your HTTP server ?
- High performance module pipeline designed for intense multithreading purposes;
- Intuitive module implementation;
- Easy to use HTTP classes;
- As any good piece of code on the internet, openZia is heavily unit tested;
- Simply because you want the best and the best is openZia !
First of all, you should check openZia's C++ Guideline to better read its code.
The API is based on a Fixed Pipeline that is composed of various callbacks.
A fixed pipeline means that you can't change it while it is running. However, you can still stop and change it at run-time by reloading modules.
The oZ::Pipeline class abstract module loading and pipeline creation on both windows and linux. oZ::Pipeline::loadModules function will search dynamic libraries in the module directory provided in pipeline's constructor.
The oZ::Context class stores the current pipeline state, network client buffer and its endpoint, HTTP request / response and an encryption key if used by the client (to implement SSL efficiently). This class is described in details in the Context guide.
oZ::Pipeline and oZ::Context are intended to be used in a State Pattern where the context hold the current state and get changed while being processed.
To implement a module you must think about when you need to add its behavior to the pipeline. Please check the detailed Module Guide for more information.
Here is a quick recap :
Override the virtual oZ::IModule::onRegisterCallbacks to register your callbacks into the pipeline.
openZia doesn't implement an HTTP parser, you must implement a specific module for that task.
You should use the different callbacks to build a oZ::HTTP::Request out of the network packet oZ::Buffer.
When the packet is successfully parsed, use the different interpret callbacks to build your response from other modules.
Each module have a callback to explicitly tell its dependencies, and another to retrieve instances to them (instead of querying them at each pipeline run), see oZ::IModule::onRetreiveDependencies.
There are no configuration abstraction classes let you freely choose how to implement it for your needs. That said, you can easily share module with independent configuration system.
Take uses of the ILogger interface create specific modules that, once loaded, will have his oZ::ILogger::onLog callback triggered each time a log is emitted.
To emit a log, use the global helper class oZ::Log.
Please take a look at the very straightforward Hello World Example file to follow a quick introduction guide.
If you are lost with cmake and don't know how to add the library to your project, follow this detailled Compilation Guide.