```php
function (MvcEvent $e) {
    $route   = $e->getRouteMatch()->getMatchedRoute();
    $request = $e->getRequest();

    if (in_array($request->getMethod(), $route->getMethods())) {
        return;
    }

    $response = $e->getReponse();

    $response->setStatusCode(405);

    return $response;
}
```

Not sure if the route config is the best place to define allowed methods, though.