https://github.com/milerius/sza
Simple Zia Api
https://github.com/milerius/sza
Last synced: over 1 year ago
JSON representation
Simple Zia Api
- Host: GitHub
- URL: https://github.com/milerius/sza
- Owner: Milerius
- License: mit
- Created: 2017-12-19T09:51:29.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2019-04-06T17:23:40.000Z (over 7 years ago)
- Last Synced: 2025-04-01T21:52:35.957Z (over 1 year ago)
- Language: C++
- Size: 218 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## SZA (Simple Zia Api)
Hi and welcome to this minimalist API. The point of this API is to restrict in no way your conception or design choices.
By giving a simple Module interface, we believe that every group will be able to build its own Zia and not just the Zia that our API requires you to create.
### Dependencies
- C++ 17
### How to build
Simply clone this repository and include the .h files in the **api** folder.
### What does SZA do :
It introduces four header files, each commented to show explicit usage :
#### - conf.h
Conf is a simple map used to configure your module, it is inspired by the JSON format.
By making ConfValue a std::variant we allow users to choose themselves how they want to configure their module.
#### - net.h
Contains :
- The NetInfo struct and its components, used to provide infos on the client
- The Net Interface for multithreaded network abstraction
#### - http.h
Contains :
- The HttpMessage struct, it contains the version, the headers and the packets
- The HttpRequest struct, it inherits from HttpMessage and adds a Method enum class and an Uri as a String
- The HttpResponse struct, it inherits from HttpMessage and adds a Status enum class
- The **HttpDuplex** struct, it contains :
1. A NetInfo struct,
2. A packets vector for req and another for resp
3. An HttpRequest struct and an HttpResponse struct.
This struct is the **core** of our API and should be the one used during the entire processing of the request.
#### - module.h
Module is the interface to use for your module, it contains two method :
- config, it takes a const Conf& and is used to configure your module depending on the state of your Conf
- exec, it takes an HttpDuplex and should be the method that **applies** your module to the current HttpDuplex
### How to use it :
After loading your modules, just simply use something like :
```C++
moduleReceive.config(conf);
moduleTreatRequest.config(conf);
moduleSend.config(conf);
for each request :
HttpDuplex http;
moduleReceive.exec(http);
moduleTreatRequest.exec(http);
moduleSend.exec(http);
```
Absolutely no need for any complicated conception when you can just use SZA.
### Doxygen :
[link](docs/doxygen/annotated.html)