无法捕获(构造)正确的路由器

时间:2019-03-23 14:57:15

标签: node.js fastify

我读了https://github.com/fastify/fastify/blob/master/docs/Routes.md

但是我的路由器似乎无法通过参数捕获正确的网址

网址:/app/name?id=666&method=3&_=1553342444710

我尝试过:

fastify.get('/app/:id-:method:*', (request, reply) => {
fastify.get('/app/*', (request, reply) => {
fastify.get('/app/:id-:method:-:_', (request, reply) => {

1 个答案:

答案 0 :(得分:1)

尝试一下:

fastify.get('/app/name', {
  schema: {
    querystring: {
      id: { type: 'integer' },
      name: { type: 'string' },
      _: { type: 'integer' },
    }
  },
},
(request, reply) => {
  ...