Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Params support in use #42

Open
pke opened this issue Nov 15, 2019 · 0 comments
Open

Params support in use #42

pke opened this issue Nov 15, 2019 · 0 comments

Comments

@pke
Copy link

pke commented Nov 15, 2019

I am not sure if that is already supported and I just don't see it. I want to "dynamically" mount a koa app with routes to a variable route like this:

const appRouter = () => {
  return new Router()
  .use(ctx => {
    // has ctx.params.app
    // has ctx.params.id if its specified in the route,
  })
  .get("/:id", ctx => {
    // has ctx.params.app
    // has ctx.params.id,
  })
  .middleware()

app.use(mount("/:app", appRouter()))

Which should enable routes like:

/myapp/1
/myapp/2

Even better if I could design the approuter to be totally unaware of the /:app part of the route and only would have to deal with its own routes. Then I would like to move the processing of potential id params to a middleware that is called before the approuter and sets some infos in the ctx before passing control to the approuter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants