Returning Method Not Allowed

When the path matches, but the HTTP method does not, your application should return a 405 Method Not Allowed status in response.

To enable that functionality, we provide Zend\Expressive\Router\Middleware\MethodNotAllowedMiddleware via the zend-expressive-router package.

This middleware triggers when the following conditions occur:

When these conditions occur, the middleware will generate a response:

Pipe the middleware after the routing middleware; if using one or more of the implicit methods middleware, this middleware must be piped after them, as it will respond for any HTTP method!

// ...

(Note: if you used the Expressive skeleton, this middleware is likely already in your pipeline.)