Closed MontealegreLuis closed 4 years ago
There isn't unfortunately, exposing that info would require a bigger change than you might think but will consider looking at it for the next major release.
@MontealegreLuis how have you been handling the OPTIONS
requests in the meantime? I assume your use case was handling pre-flight requests.
I've been searching for a clean way to handle them seeing as they're sent for each requested route, and there's no *
catchall pattern for urls.
I'm also interested in knowing how to handle pre-flight requests globally...
+1
Is there a way to run the match method manually and get the list of endpoints a given path matches to? I am interested in using this information to extract the methods that are already mapped and respond with the appropriate Allow
header for OPTIONS
.
$endpoints['/test/{arg1}'] = ['GET','POST'];
$methods_allowed = $endpoints[matchedendpoint('/test/hello-world')];
So I've gone with automatically generating OPTIONS routes (if they haven't been defined), with the handler/controller existing on the Strategy, therefore easily extensible with custom strategies.
Is there a way to create/add a generic middleware to respond to
OPTIONS
HTTP method.I made a small test and
OPTIONS
returns a405
response for theJsonStrategy
But I don't think there's information about the route that a middleware could use.