Skip to content

Add an option to disable the wildcard route or to select the ones to be enabled #420

Open
@edocrippaofficial

Description

@edocrippaofficial

Prerequisites

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

🚀 Feature Proposal

The proposal is to have a way to select what route to create between the standard one and the one with the wildcard.

This is the current implementation (both routes are created):

fastify.route({
    url: '/',
    method: opts.httpMethods || httpMethods,
    preHandler,
    config: opts.config || {},
    constraints: opts.constraints || {},
    handler
})
fastify.route({
    url: '/*',
    method: opts.httpMethods || httpMethods,
    preHandler,
    config: opts.config || {},
    constraints: opts.constraints || {},
    handler
})

There may be an option to disable the wildcard route or to select those to be enabled.
I can do this myself if the idea seems reasonable.

Motivation

If I want to create a route for the /foo path, I also want Fastify to return a 404 response to the /foo/bar route, without trying to forward it to the downstream if not wanted.

Example

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions