Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Http/REST method for starting a service

Tags:

rest

http

I want to design a REST API to start a database. I can't find a suitable http method (aka verb).

I currently consider:

START /databases/mysampledatabase

I've browsed through a few RFCs, but then I thought someone here might point me to a de-facto standard verb.

Methods I've discarded (before I got tired of looking):

RFC 2616 OPTIONS GET HEAD POST PUT DELETE TRACE CONNECT

RFC 2518 PROPFIND PROPPATCH MKCOL COPY MOVE LOCK UNLOCK

RFC 3253 REPORT CHECKOUT CHECKIN UNCHECKOUT MKWORKSPACE UPDATE LABEL MERGE BASELINE-CONTROL MKACTIVITY

like image 593
Jack Wester Avatar asked Feb 26 '13 23:02

Jack Wester


1 Answers

There's a bunch of thinking flaws here.. first off, the additional HTTP verbs (aside from the CRUD ones) should be considered not-restful.

So there's two ways I can interpret this question, and I have an answer for both:

1. What's the most appropriate HTTP method for starting a service

There's nothing quite like what you need, and I would advise simply using POST.

2. What's a good RESTful way to start a service

First, you should not see 'starting the service' as the action. It's easier to think of the 'status' (being started or stopped) as the resource you are changing, and PUT to update the resource.

So in this case, each service should have a unique uri. A GET on that uri could return something like :

{ "status" : "stopped" }

You just change 'stopped' to 'started', PUT the new resource.. and then the service could automatically begin running.

I wonder how useful this is though.. I'm not a REST zealot, and I think a simple POST is the best way to go..

like image 162
Evert Avatar answered Nov 07 '22 07:11

Evert