10#ifdef ORBIT_ENABLE_HTTP3
13namespace server {
class QuicConnectionManager; }
61 router_.
group(prefix, std::move(callback));
72 return router_.
route(path, method);
172#define ORBIT_DEFINE_ROUTER_TEMPLATES(METHOD) \
173 template <typename Handler> \
174 App& METHOD(const std::string& path, Handler&& handler) { \
175 return METHOD(path, routing::wrap_handler(std::forward<Handler>(handler))); \
177 template <typename Handler> \
178 App& METHOD(const std::string& path, std::vector<routing::Middleware> mws, Handler&& handler) { \
179 return METHOD(path, std::move(mws), routing::wrap_handler(std::forward<Handler>(handler))); \
188#undef ORBIT_DEFINE_ROUTER_TEMPLATES
198 router_.
ws(path, std::move(handler));
208 if (!event_loop_)
throw std::runtime_error(
"Server not started");
209 return event_loop_->get_thread_pool();
230 const std::string& version =
"1.0.0",
231 const std::string& docs_path =
"/docs",
232 const std::string& json_path =
"/swagger.json");
255 std::unique_ptr<Listener> listener_;
256#ifdef ORBIT_ENABLE_HTTP3
257 std::unique_ptr<network::UdpSocket> quic_socket_;
258 std::unique_ptr<QuicConnectionManager> quic_manager_;
260 std::unique_ptr<network::TlsContext> tls_context_;
261 std::unique_ptr<EventLoop> event_loop_;
#define ORBIT_DEFINE_ROUTER_TEMPLATES(METHOD)
Definition App.hpp:172
Definition ThreadPool.hpp:12
A builder class for fluent route configuration.
Definition Router.hpp:43
Manages routing of HTTP requests to their appropriate handlers.
Definition Router.hpp:30
void ws(const std::string &path, WsHandler handler)
Definition Router.cpp:214
RouteBuilder route(const std::string &path, http::HttpMethod method=http::HttpMethod::GET)
Initiates a route builder for a specific path and method.
Definition Router.hpp:75
void group(const std::string &prefix, std::function< void(Router &)> callback)
Creates a route group with a specific prefix.
Definition Router.cpp:48
The main application class for the Orbit Framework.
Definition App.hpp:26
App & options(const std::string &path, routing::RouteHandler handler)
Registers an OPTIONS route.
App & operator=(const App &)=delete
App & put(const std::string &path, routing::RouteHandler handler)
Registers a PUT route.
routing::Router::RouteBuilder route(const std::string &path, http::HttpMethod method=http::HttpMethod::GET)
Initiates a route builder for a specific path and method.
Definition App.hpp:71
App & post(const std::string &path, std::vector< routing::Middleware > mws, routing::RouteHandler handler)
Registers a POST route with middleware.
App & ws(const std::string &path, routing::WsHandler handler)
Registers a WebSocket route.
Definition App.hpp:197
concurrency::ThreadPool & get_thread_pool()
Retrieves the application's thread pool.
Definition App.hpp:207
void hot_reload()
Triggers a hot reload of the server configuration and routes.
void stop()
Gracefully stops the server.
App & group(const std::string &prefix, std::function< void(routing::Router &)> callback)
Creates a route group with a specific prefix.
Definition App.hpp:60
App & patch(const std::string &path, routing::RouteHandler handler)
Registers a PATCH route.
App & use(routing::Middleware m)
Registers a global middleware.
App & patch(const std::string &path, std::vector< routing::Middleware > mws, routing::RouteHandler handler)
Registers a PATCH route with middleware.
App & del(const std::string &path, std::vector< routing::Middleware > mws, routing::RouteHandler handler)
Registers a DELETE route with middleware.
App & options(const std::string &path, std::vector< routing::Middleware > mws, routing::RouteHandler handler)
Registers an OPTIONS route with middleware.
App & put(const std::string &path, std::vector< routing::Middleware > mws, routing::RouteHandler handler)
Registers a PUT route with middleware.
App & del(const std::string &path, routing::RouteHandler handler)
Registers a DELETE route.
void listen()
Starts the server and blocks the current thread.
App & enable_openapi(const std::string &title="Orbit Framework API", const std::string &version="1.0.0", const std::string &docs_path="/docs", const std::string &json_path="/swagger.json")
Enables OpenAPI documentation and Swagger UI.
App & enable_metrics(const std::string &path="/metrics")
Enables Prometheus metrics endpoint.
App(const config::ServerConfig &config)
Constructs a new App instance.
void on_error(routing::ErrorHandler handler)
Registers a global error handler for the application.
App & get(const std::string &path, std::vector< routing::Middleware > mws, routing::RouteHandler handler)
Registers a GET route with middleware.
App & get(const std::string &path, routing::RouteHandler handler)
Registers a GET route.
App & post(const std::string &path, routing::RouteHandler handler)
Registers a POST route.
HttpMethod
Represents standard HTTP methods.
Definition HttpRequest.hpp:17
std::function< bool(http::HttpRequest &, std::shared_ptr< http::ResponseWriter >)> Middleware
Definition Router.hpp:17
std::function< void(const std::exception &, http::HttpRequest &, std::shared_ptr< http::ResponseWriter >)> ErrorHandler
Definition Router.hpp:19
std::function< void(http::HttpRequest &, std::shared_ptr< http::ResponseWriter >)> RouteHandler
Definition Router.hpp:16
std::function< void(http::websocket::WebSocketConnection &)> WsHandler
Definition Router.hpp:18
Definition Http2Session.hpp:17