Skip to content

Commit

Permalink
Enable GZIP compression for API server
Browse files Browse the repository at this point in the history
- Added CROW_ENABLE_COMPRESSION flag in CMakeLists.txt
- Updated api_server.cpp to use GZIP compression with Crow framework
- Modified api_server.hpp to include compression headers and define compression macro

This change improves API response efficiency by enabling GZIP compression for network communication.
  • Loading branch information
Joachim Rosskopf committed Jan 27, 2025
1 parent af0a202 commit 6fdab7c
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
set(CROW_ENABLE_COMPRESSION ON)

# Compiler flags
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
Expand Down
2 changes: 1 addition & 1 deletion src/api_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,10 @@ void APIServer::run(int port) {
app.port(configManager->getHttpPort())
.server_name("flAPI")
.multithreaded()
.use_compression(crow::compression::GZIP)
.run();
}


void APIServer::requestForEndpoint(const EndpointConfig& endpoint, const std::unordered_map<std::string, std::string>& pathParams)
{
auto req = crow::request();
Expand Down
2 changes: 2 additions & 0 deletions src/include/api_server.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#pragma once

#define CROW_ENABLE_COMPRESSION
#include <crow.h>
#include "crow/middlewares/cors.h"
#include "crow/compression.h"

#include "auth_middleware.hpp"
#include "config_manager.hpp"
Expand Down

0 comments on commit 6fdab7c

Please sign in to comment.