mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-10-15 18:14:44 +00:00
Add openai mode
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "services/logging/logger.h"
|
||||
#include "web_client/web_client.h"
|
||||
@@ -39,6 +40,22 @@ class HttpWebClient final : public WebClient {
|
||||
*/
|
||||
std::string Get(const std::string& url) override;
|
||||
|
||||
/**
|
||||
* @brief Executes a blocking HTTP/HTTPS POST request against a full URL.
|
||||
*
|
||||
* Sends @p body with a "Content-Type: application/json" header, plus any
|
||||
* additional headers supplied by the caller (e.g. authentication).
|
||||
*
|
||||
* @param url Fully-qualified URL.
|
||||
* @param body Request body, sent as-is.
|
||||
* @param headers Additional request headers.
|
||||
* @return Response body on HTTP 2xx; throws std::runtime_error otherwise.
|
||||
*/
|
||||
std::string Post(
|
||||
const std::string& url, const std::string& body,
|
||||
const std::vector<std::pair<std::string, std::string>>& headers)
|
||||
override;
|
||||
|
||||
/**
|
||||
* @brief Percent-encodes a single URI component (query parameter value or
|
||||
* path segment). Delegates to httplib::encode_uri_component().
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
/**
|
||||
* @brief Abstract web client interface.
|
||||
@@ -23,6 +25,20 @@ class WebClient {
|
||||
*/
|
||||
virtual std::string Get(const std::string& url) = 0;
|
||||
|
||||
/**
|
||||
* @brief Executes an HTTP POST request with a JSON body.
|
||||
*
|
||||
* @param url Request URL.
|
||||
* @param body Request body (sent as-is; callers are responsible for
|
||||
* providing valid JSON when the target API expects it).
|
||||
* @param headers Additional request headers (e.g. authentication),
|
||||
* sent alongside a fixed "Content-Type: application/json" header.
|
||||
* @return Response body.
|
||||
*/
|
||||
virtual std::string Post(
|
||||
const std::string& url, const std::string& body,
|
||||
const std::vector<std::pair<std::string, std::string>>& headers) = 0;
|
||||
|
||||
/**
|
||||
* @brief URL-encodes a string value.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user