", $req->getRequestTarget())) { // if the request path is more than an empty string or a slash, the client is probably trying a version we don't support return new EmptyResponse(404); } switch ($req->getMethod()) { case "OPTIONS": // if the request method is OPTIONS, respond accordingly return new EmptyResponse(204, ['Allow' => "HEAD,GET"]); case "GET": // otherwise return the supported versions $out = [ 'apiLevels' => [ 'v1-2', ] ]; return new Response($out); default: // if any other method was used, this is an error return new EmptyResponse(405, ['Allow' => "HEAD,GET"]); } } }