Crow:蓝图路由1 CROW_BP_ROUTE

蓝图路由简单点说可以认为先给路由设置一个根目录,然后在该根目录下设置子路由,比如:

设置蓝图路由为/user/,然后添加子路由add, delete,那么总的路由相当于:

/user/add和/user/delete

看一下Crow的实现:

#define CROW_ROUTE(app, url) app.template route(url)

#define CROW_BP_ROUTE(blueprint, url) blueprint.new_rule_tagged(url)

可以看到CROW_BP_ROUTE跟CROW_ROUTE还是很像的

其第一个参数是一个blueprint对象

class Blueprint
{
public:
    Blueprint(const std::string& prefix):
      prefix_(prefix){};
    template
    typename black_magic::arguments::type::template rebind& new_rule_tagged(std::string&& rule)
    {
        std::string new_rule = std::move(rule);
        new_rule = '/' + prefix_ + new_rule;
        using Rule

你可能感兴趣的:(Crow,c++)