Parse commit request

This commit is contained in:
2025-09-03 21:53:04 -04:00
parent 46edb7cd26
commit 978861c430
3 changed files with 112 additions and 36 deletions

View File

@@ -13,6 +13,10 @@
#include "server.hpp"
#include "thread_pipeline.hpp"
// Forward declarations
struct CommitRequest;
struct JsonCommitRequestParser;
/**
* HTTP routes supported by WeaselDB server.
* Using enum for efficient switch-based routing.
@@ -56,6 +60,11 @@ struct HttpConnectionState {
bool header_field_complete = false;
int64_t request_id = 0; // X-Request-Id header value
// Streaming parser for POST requests
std::unique_ptr<JsonCommitRequestParser> commit_parser;
std::unique_ptr<CommitRequest> commit_request;
bool parsing_commit = false;
explicit HttpConnectionState(ArenaAllocator &arena);
};
@@ -176,10 +185,10 @@ private:
static void sendResponse(Connection &conn, int status_code,
std::string_view content_type, std::string_view body,
bool close_connection = false);
static void sendJsonResponse(Connection &conn, int status_code,
std::string_view json,
bool close_connection = false);
static void sendErrorResponse(Connection &conn, int status_code,
std::string_view message,
bool close_connection = false);
static void send_json_response(Connection &conn, int status_code,
std::string_view json,
bool close_connection = false);
static void send_error_response(Connection &conn, int status_code,
std::string_view message,
bool close_connection = false);
};