前面已经介绍了Crow如何添加路由,添加插件,以及路由和插件的运行的机制,那么Crow本身是怎么运行起来的呢?
template<typename... Middlewares>
class Crow
{...template<typename... Middlewares>using App = Crow<Middlewares...>;using SimpleApp = Crow<>;
};
Crow类声明了两个别名,App用于带有插件的,SimpleApp用于不带插件的
template<typename... Middlewares>
class Crow
{...Crow(){}/// Construct Crow with a subset of middlewaretemplate<typename... Ts>Crow(Ts&&... ts):middlewares_(make_middleware_tuple(std::forward<Ts>(ts)...)){}...std::tuple<Middlewares...> middlewares_;
};
Crow的构造函数,使用模版参数初始化
参考