fastify-method-override

1.5.10 • Public • Published

fastify-method-override

github action status Codacy Badge test coverage npm version

Plugin for Fastify, which allows use HTTP verbs, such as DELETE, PATCH, HEAD, PUT, OPTIONS in case the client doesn't support them. Supports Fastify versions >=2.0.0.

Install

$ npm install fastify-method-override

Usage

import fastify from 'fastify';
import fastifyMethodOverride from 'fastify-method-override';

const app = fastify();

app.register(fastifyMethodOverride);

To override the HTTP method, use the HTML form with the hidden _method field and the value of the target method:

<form method="POST" action="/url">
  <input type="hidden" name="_method" value="DELETE">
  <input type="submit" value="Submit">
</form>

Note

If you use setNotFoundHandler, the plugin may not work correctly. In order to override the standard 404 error handler, you must use setErrorHandler.

If you are having trouble using the plugin, you can use the fastify-method-override-wrapper library.

Package Sidebar

Install

npm i fastify-method-override

Weekly Downloads

55

Version

1.5.10

License

MIT

Unpacked Size

8.38 kB

Total Files

4

Last publish

Collaborators

  • corsicanec82