http: enclose libevent-dependent code in a namespace

This commit is a no-op to isolate HTTP methods and objects that
depend on libevent. Following commits will add replacement objects
and methods in a new namespace for testing and review before
switching over the server.
This commit is contained in:
Matthew Zipkin
2024-09-30 12:28:54 -04:00
parent 5aa3629b48
commit 89c54ae4cb
8 changed files with 25 additions and 5 deletions

View File

@@ -30,6 +30,8 @@ static const int DEFAULT_HTTP_SERVER_TIMEOUT=30;
struct evhttp_request;
struct event_base;
class CService;
namespace http_libevent {
class HTTPRequest;
/** Initialize HTTP server.
@@ -48,9 +50,10 @@ void StopHTTPServer();
/** Change logging level for libevent. */
void UpdateHTTPServerLogging(bool enable);
} // namespace http_libevent
/** Handler for requests to a certain HTTP path */
typedef std::function<void(HTTPRequest* req, const std::string &)> HTTPRequestHandler;
typedef std::function<void(http_libevent::HTTPRequest* req, const std::string &)> HTTPRequestHandler;
/** Register handler for prefix.
* If multiple handlers match a prefix, the first-registered one will
* be invoked.
@@ -59,6 +62,7 @@ void RegisterHTTPHandler(const std::string &prefix, bool exactMatch, const HTTPR
/** Unregister handler for prefix */
void UnregisterHTTPHandler(const std::string &prefix, bool exactMatch);
namespace http_libevent {
/** Return evhttp event base. This can be used by submodules to
* queue timers or custom events.
*/
@@ -158,6 +162,7 @@ public:
* @param[in] key represents the query parameter of which the value is returned
*/
std::optional<std::string> GetQueryParameterFromUri(const char* uri, const std::string& key);
} // namespace http_libevent
/** Event class. This can be used either as a cross-thread trigger or as a timer.
*/