RoutingGroup

RoutingGroupを使うと、階層構造をまとめて記述でき、ルーティングの$pathを簡素化できます。

group($prefix, $callback)

group("/article", function($g){
  // /article/list
  $g->get("/list", function(){});

  $g->group("/detail/(\d+)", function($g){
    // /article/detail/(\d+)
    $g->get("", function($id){});

    // /article/detail/(\d+)/comments
    $g->get("/comments", function($id){});
    $g->post("/comments", function($id){});
  });
});