azagniotov/stubby4j

Enhancement: Allow negated list of methods for requests

Closed this issue · 2 comments

The basic use case I'm looking at it that an endpoint can take a GET (and only a GET), and any other methods will produce a 405 (method not supported). I know I can emulate this by listing all of the methods that are not permitted, but it seems like it would be helpful to be able to specify "anything other than these methods". Possible forms that come to mind are:

    method: !GET          # Or some marker to negate
    method: [!GET, !POST] # List with same marker to negate
    method: ^(?!GET).+$   # Use negative-lookahead regex

Alternatively, perhaps a runtime option to render a 405 when a URL is matched, but not the method?

Hi @daecabhir

Thank you for suggesting this. I am contemplating if to make it a default behavior, i.e.: an endpoint can take a GET (and only a GET), and any other methods will produce a 405 (method not supported).

If you think that would be an appropriate default behavior, that works just fine for me. Thank you!