alexp95
alexp9515mo ago

How do I have a subrouter in Oak?

I want to use a subrouter in oak to handle part of the routing, how would I do that in Oak? here is an example in Express.js
app.use("/path/to/subrouter", subrouter);
app.use("/path/to/subrouter", subrouter);
4 Replies
akumaruь
akumaruь15mo ago
Hi there. I've used Express before, But first time seeing something like subrouter, can you provide a link, please?
fro.profesional
fro.profesional15mo ago
GitHub
GitHub - oakserver/oak: A middleware framework for handling HTTP wi...
A middleware framework for handling HTTP with Deno 🐿️ 🦕 - GitHub - oakserver/oak: A middleware framework for handling HTTP with Deno 🐿️ 🦕
Mongalorian
Mongalorian15mo ago
You should be able to nest routers like this:
router.use(
'/subroute',
subRouter.routes(),
subRouter.allowedMethods(),
)
router.use(
'/subroute',
subRouter.routes(),
subRouter.allowedMethods(),
)
alexp95
alexp95OP15mo ago
it worked, thank you!

Did you find this page helpful?