Fastify: How does one do a "rest parameter"-like route?

Created on 24 Sep 2018  路  3Comments  路  Source: fastify/fastify

I'd want it to satisfy /one/two/three/four and /one/two/three/four/five, etc.

I have tried

fastify.get("/:foo/:bar/:baz+", require("./routes/baz"))

and

fastify.get("/:foo/:bar/(.*)", require("./routes/baz"))

to no avail. Any ideas?

question

Most helpful comment

To all the lurkers who needed this stupid question to be asked,

All 3 comments

Hello!
You can use a wildcard, eg:

fastify.get('/:foo/:bar/*', (req, reply) => {
  console.log(req.params) // { foo: 'one', bar: 'two', *: 'three/four' }
})

To all the lurkers who needed this stupid question to be asked,

No question is a stupid question :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lgertel picture lgertel  路  3Comments

avilang picture avilang  路  3Comments

rqbazan picture rqbazan  路  3Comments

PacoDu picture PacoDu  路  3Comments

zairl23 picture zairl23  路  3Comments