Skip to content

Nested sub apps and parameter extractors #186

@pke

Description

@pke

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions