@darthcav/ts-http-server
    Preparing search index...

    Function createMethodNotAllowedHandler

    • Creates a Fastify route handler that responds with 405 Method Not Allowed, advertising the permitted methods via the Allow header (RFC 9110 §10.2.1).

      Intended for the catch-all route of a path whose allowed methods are handled by separate route definitions, e.g.:

      routes.set("INDEX_405", {
      method: ["DELETE", "PATCH", "POST", "PUT", "OPTIONS"],
      url: "/",
      handler: createMethodNotAllowedHandler(["GET", "HEAD"]),
      })

      Parameters

      • allowedMethods: string[]

        The HTTP methods permitted on the route, joined into the Allow response header (e.g. ["GET", "HEAD"]).

      Returns RouteHandlerMethod<
          RawServerDefault,
          IncomingMessage,
          ServerResponse<IncomingMessage>,
          RouteGenericInterface,
          unknown,
          FastifySchema,
          FastifyTypeProviderDefault,
          FastifyBaseLogger,
      >

      A Fastify route handler that sets the Allow header and throws a Boom 405 error.