After reviewing the issue I found a work around for this issue. The reason I wanted this feature was to encapsulate the routing logic in different modules. My solution is :
// router/index.ts
import { Router } from "https://deno.land/x/oak/mod.ts";
import withAccountRoutes from "./account.ts";
import withContractRoutes from "./contract.ts";
const router = new Router();
withAccountRoutes(router);
withContractRoutes(router);
export default router;
// router/account.ts
import { Router } from "https://deno.land/x/oak/mod.ts";
const SUB_ROUTE = "/account";
const withAccountRoutes = (router: Router) => {
router
.get(SUB_ROUTE + "/new", ({ request, response, cookies }) => {
console.log("Cookies : ", cookies);
response.body = "Will be avaiable soon";
})
.get(SUB_ROUTE + "/current", ({ request, response, cookies }) => {
response.body = "You are the wise one";
});
};
export default withAccountRoutes;