Crow/examples/example_compression.cpp
The-EDev ca31b85156 added CROW_ENABLE_COMPRESSION macro to enable zlib compression
This makes zlib dependency (which is quite problematic) optional
2021-06-03 17:12:20 +03:00

32 lines
736 B
C++

#define CROW_MAIN
#define CROW_ENABLE_COMPRESSION
#include "crow.h"
#include "crow/compression.h"
int main()
{
crow::SimpleApp app;
//crow::App<crow::CompressionGzip> app;
CROW_ROUTE(app, "/hello")
([&](const crow::request&, crow::response& res){
res.compressed = false;
res.body = "Hello World! This is uncompressed!";
res.end();
});
CROW_ROUTE(app, "/hello_compressed")
([](){
return "Hello World! This is compressed by default!";
});
app.port(18080)
.use_compression(crow::compression::algorithm::DEFLATE)
//.use_compression(crow::compression::algorithm::GZIP)
.loglevel(crow::LogLevel::Debug)
.multithreaded()
.run();
}