Finding supported methods for an OPTION request

Working on an API I was wondering about how to find the supported request methods for a request in a good and feasible way.

At the moment I’m thinking about using the routes configuration and find all defined routes that ‘match’ the current pattern (also keeping optional parts in mind). That way it should be possible to find all request methods that are supported by the configured routes.

This list could then be filtered by checking if the controller / actions are actually accessible in the current security context.

Is this a feasible way in your opinion? And if not, are there other approaches that are better?

2 Likes