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

bhanuc picture bhanuc  路  4Comments

valentinvichnal picture valentinvichnal  路  3Comments

allevo picture allevo  路  3Comments

rabbitooops picture rabbitooops  路  3Comments

Jegannathan picture Jegannathan  路  3Comments