Reputation: 86
I am using Katharsis library in my Spring Boot server to build automatically JSON-API interface.
Let's say I have an endpoint (resource) /resource, for which I would like to offer POST method (to create new resources) but restrict PATCH (to restrict resources updating). Meanwhile, the io.katharsis.repository.ResourceRepository offers only save() method, which applies to both POST and PATCH.
My only idea at the moment is to add another Filter to FilterChain that will disallow PATCHing the required endpoint.
Are there any better (i.e. shorter or more elegant) ways to achieve this?
Upvotes: 0
Views: 861
Reputation: 36
A PATCH contains an ID.
So you could check if ID != null and throw an error instead.
On this way you don't need to check the database.
This solution assumes that you don't generate id's on the client.
Upvotes: 0
Reputation: 516
To disable PATCH method you should follow the steps:
Upvotes: 0