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

Nested sub apps and parameter extractors #186

Open
pke opened this issue Sep 27, 2022 · 0 comments
Open

Nested sub apps and parameter extractors #186

pke opened this issue Sep 27, 2022 · 0 comments

Comments

@pke
Copy link

pke commented Sep 27, 2022

Coming back to polka after a few years I have problems mounting sub-apps which was easy to do in koa.

I'd like to have these URLs:

/app/:appid/client/:clientid

where a middleware extracts the proper req.app from the appid and another middleware extracts req.client from clientid

My sub-apps I structured like this:

const client = polka()
  .use(req, res, next) => {
    req.client = getClient(req.params.clientid)    
    next()
  })
  .get("/", ...)

const app = polka()
  .use((req, res, next) => {
    req.app = getApp(req.params.appid)    
    next()
  })
  .get("/", ...)
  .use("client", client)

but the URL mentioned about does end up in 404.

btw: do you want to enable "Discussions" here so we don't use issues for simple Q&A?

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

1 participant