question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Background

currently egg don’t support sub router, but koa-router provide prefix() feature.

Proposal

  • provide app.namespace([prefix], [middlewares]).verb()
  • app.url() will traverse all the router, return the first one

example:

// app/router.js
module.exports = app => {
  app.get('/', 'home.index');

  const adminRouter = app.namespace('/admin');
  // GET /admin
  adminRouter.get('/', 'admin.index');
  // GET /admin/user
  adminRouter.get('/user', 'admin.user');
}

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:5
  • Comments:16 (13 by maintainers)

github_iconTop GitHub Comments

2reactions
atian25commented, Dec 9, 2017

https://github.com/atian25/egg-router-plus/pull/1

写了个插件,下周再完善下

2reactions
dead-horsecommented, May 11, 2017
  1. 不想在 egg-core 里面提供这个功能,希望是一个扩展的 router 插件,这样也便于大家选择自己喜欢的 router 使用方式,egg-core 只提供基础的 app.verb()
  2. 需要考虑中间件的支持
const router = app.getRouter('/sub', middleware);
router.get('/test1', 'test1');
router.get('/test2', 'test2');

// or

app.namespace('/sub', middleware, router => {
  router.get('/test1', 'test1');
  router.get('/test2', 'test2');
});
Read more comments on GitHub >

github_iconTop Results From Across the Web

RFC 1812: Requirements for IP Version 4 Routers
1 INTRODUCTION An Interior Gateway Protocol (IGP) is used to distribute routing information between the various routers in a particular AS. · 2...
Read more >
RFC 1812 Requirements for IP Version 4 Routers - IETF
The complete set of requirements for an Internet protocol router is primarily defined in the standard protocol specification documents, with the corrections, ...
Read more >
OSPF Cost of the summary route with RFC 1583 and RFC 2328
-By default the routers implement the old RFC 1583, which means the cost of the summary route is. the lowest metric of the...
Read more >
Blog - Layouts RFC | Next.js
Nested routes and layouts, client and server routing, React 18 features, and designed for Server Components.
Read more >
[RFC]: Modal based routing · Issue #5890 · redwoodjs/redwood
I was actually trying to animate my modal sub-views (in my hacked together modal routing solution) to be able to slide between each...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found