Вопрос

Currently I'm working on a CMS containing on a RESTful webservice. For the regular REST actions, I use the default HTTP methods GET, PUT, POST and DELETE. However, I'm thinking of adding a custom method MAINTENANCE, which I can use for maintenance purposes, like integrity checks, re-indexing, etc. These kind of maintenance can only be invoked by administrators of the CMS.

My webservice supports overriding the HTTP method by defining the url parameter _method. This way I can 'post' a form, setting the _method to PUT. I can also use this same parameter to set the method to MAINTENANCE. Technically it is fairly easy to implement a custom HTTP method.

My questions is more ethical about proper design. On one hand, custom HTTP methods are allowed and technically not difficult to implement. On the other hand, some people advice not to use custom HTTP methods.

Should I use custom HTTP methods for maintenance tasks? Or are there other best practices?

Это было полезно?

Решение

Integrity checks and re-indexing are not resource actions that you want to expose to a user. These can be achieved via a different servlet that's non_REST.

Adding more methods to HTTP is not a normal practice. You can look some to the REST interfaces that are public.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top