20#ifndef ORES_HTTP_NET_HTTP_SERVER_HPP
21#define ORES_HTTP_NET_HTTP_SERVER_HPP
25#include <boost/asio/io_context.hpp>
26#include <boost/asio/ip/tcp.hpp>
27#include <boost/asio/awaitable.hpp>
28#include "ores.http.api/net/router.hpp"
29#include "ores.http.api/net/http_session.hpp"
30#include "ores.http.api/net/http_server_options.hpp"
31#include "ores.security/jwt/jwt_authenticator.hpp"
32#include "ores.http.api/openapi/endpoint_registry.hpp"
33#include "ores.logging/make_logger.hpp"
35namespace ores::http::net {
42 explicit http_server(boost::asio::io_context& io_ctx,
53 std::shared_ptr<openapi::endpoint_registry>
get_registry() {
return registry_; }
58 std::shared_ptr<ores::security::jwt::jwt_authenticator>
get_authenticator() {
return authenticator_; }
67 bytes_callback_ = std::move(callback);
73 boost::asio::awaitable<void>
run();
86 inline static std::string_view logger_name =
"ores.http.net.http_server";
90 static auto instance = make_logger(logger_name);
94 void setup_builtin_routes();
96 boost::asio::awaitable<void> accept_connections();
98 boost::asio::io_context& io_ctx_;
99 http_server_options options_;
100 std::shared_ptr<router> router_;
101 std::shared_ptr<ores::security::jwt::jwt_authenticator> authenticator_;
102 std::shared_ptr<openapi::endpoint_registry> registry_;
103 std::unique_ptr<boost::asio::ip::tcp::acceptor> acceptor_;
104 std::atomic<bool> running_{
false};
105 std::atomic<std::uint32_t> active_connections_{0};
106 session_bytes_callback bytes_callback_;
Implements logging infrastructure for ORE Studio.
Definition boost_severity.hpp:28
HTTP server built on Boost.Beast.
Definition http_server.hpp:40
bool is_running() const
Returns whether the server is running.
Definition http_server.hpp:83
void set_session_bytes_callback(session_bytes_callback callback)
Sets the session bytes callback for tracking request/response sizes.
Definition http_server.hpp:66
std::shared_ptr< router > get_router()
Returns the router for registering endpoints.
Definition http_server.hpp:48
std::shared_ptr< ores::security::jwt::jwt_authenticator > get_authenticator()
Returns the JWT authenticator for token generation/validation.
Definition http_server.hpp:58
void stop()
Signals the server to stop accepting new connections.
Definition http_server.cpp:169
std::shared_ptr< openapi::endpoint_registry > get_registry()
Returns the endpoint registry for OpenAPI generation.
Definition http_server.hpp:53
boost::asio::awaitable< void > run()
Starts the server and accepts connections.
Definition http_server.cpp:101
Configuration options for the HTTP server.
Definition http_server_options.hpp:33