Skip to content

Please add route shorthand declarations for the remaining supported http methods. #4405

@smallandsimple

Description

@smallandsimple

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the feature has not already been requested

(Similar but not identical to issue #9)

🚀 Feature Proposal

Currently, the Fastify shorthand declarations are limited to:
fastify.get(path, [options], handler)
fastify.head(path, [options], handler)
fastify.post(path, [options], handler)
fastify.put(path, [options], handler)
fastify.delete(path, [options], handler)
fastify.options(path, [options], handler)
fastify.patch(path, [options], handler)

Please add shorthand methods for the other valid route methods:
'SEARCH', 'TRACE', 'PROPFIND', 'PROPPATCH', 'MKCOL', 'COPY', 'MOVE', 'LOCK' and 'UNLOCK'

Motivation

My organization has planned to begin using the search http method and phase out the use of POST for routes that query with a JSON body. We currently use the shorthand declarations and would like to be able to maintain that consistency, as we also are phasing out and migrating from Express.js to Fastify.

Example

const fastify = require('fastify')({ logger: true })

fastify.search('/', async (request, reply) => {
  return { found: 'world' }
})

const start = async () => {
  try {
    await fastify.listen({ port: 3000 })
  } catch (err) {
    fastify.log.error(err)
    process.exit(1)
  }
}
start()

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issueGood for newcomerssemver-minorIssue or PR that should land as semver minorv5.xIssue or pr related to Fastify v5

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions