18class App :
public ContextApp<ContextType> {
22 std::shared_ptr<ContextType> dataStore;
23 std::shared_ptr<routing::BaseRouter> router;
25 std::shared_ptr<Middlewares<ContextType>> middlewares;
30 std::shared_ptr<ContextType> dataStore,
32 std::optional<raven::SSLConfig>&& sslConfig = std::nullopt
33 ): ContextApp<ContextType>(std::move(conf)),
37 this->config.concurrency,
38 this->config.bindAddr,
45 dataStore->app = (
BaseApp*)
this;
50 template <
typename = std::enable_if<std::is_trivially_default_constructible_v<ContextType>>>
53 std::optional<raven::SSLConfig>&& sslConfig = std::nullopt
54 ): App(std::make_shared<ContextType>(), std::move(conf), std::move(sslConfig)) {
74 Method::HttpMethod method
77 const routing::RouteCallback<path, ContextType>& callback
79 return std::static_pointer_cast<routing::Router<ContextType>>(router)
80 ->
template registerRoute<path>(
90 void shutdown()
override {
95 return this->serv.getPort();
102 const routing::BaseRouter& getRouter()
override {
103 return *this->router;
106 data::CommonData* getContext()
const override {
107 return this->dataStore.get();
110 void registerGlobalMiddlewares(
111 const std::vector<std::shared_ptr<Middleware<ContextType>>>& middlewares
113 this->middlewares->middlewares = middlewares;
116 Middlewares<ContextType>* getMiddlewaresAsPtr()
override {
117 return this->middlewares.get();