#include "src/webserver.h"
int main(int argc, const char **argv) {
http::webserver server(
".",
8001,
512,
4);
server.get("/", [](parsed_request& request, packet_response& response, f_cache &cache) {
response.set_body_content(cache->fetch("index.html"));
response.set_content_type("text/html");
response.set_content_status(200);
});
server.run();
return 0;
}- Keep-alive support
- In house json implementation
- Automatic ip and activity logger
- Non main thread blocking so you can use it on top of other application's
- Automatic static content caching and retrival
- File caching for enhanced responsivness
-
Can be used to change the packet size when iteracting with a client
#define BUFFER_SIZE 1024 #include "webserver.h"
-
Can be used to change the memory slots allocated for the inbuild LRU file cache
#define CACHE_SIZE 72 #include "webserver.h"
-
Can be used to change the session timeout limit
#define CONNECTION_TIMEO 300 //5 minutes #include "webserver.h" -
Files logged via the inbuild logger need to create a new file once it reaches a certain size to improve long term performance. Using this macro will enable you to customize that limit
#define LOGGER_MAX_LOG_SIZE 5 * 1024 * 1024 // ~5mb #include "webserver.h" -
DO NOT USE
This is used in testing and WILL reduce performace as this macro causes the program to close and reopen the log file to save the appended content. By default this is set to "LOGGER_MAX_LOG_SIZE", another macro used to change log file sizes#define LOGGER_ENABLE_AUTO_WRITE LOGGER_MAX_LOG_SIZE #include "webserver.h"