Issue #057 [Accepted/open] - Make macros more RESTful

Posted by mrevil@asvachin.eu

What steps will reproduce the problem?

  1. Try to make a macro that responds to anything other than POST

WebIOPi version used? => rev 1243

Python version used? => 3.2

Here's a patch to that does the following:

  1. Allows macros to have their HTTP method specified (from GET, POST, PUT or DELETE), so that the API can be customized in a RESTful way.
  2. Allows macros to receive arguments from any or all of the URL, query string, or request body.
  3. Allow macros to specify their URL independently of the function name, and without needing the 'macros' prefix.
  4. Handle the content-type header properly in both request and response.

It doesn't allow the HTTP response codes to be set though (other 2xx response codes, 404 etc. should be returned as appropriate to comply with the standards).

Also attached is a quick example of what this allows.

Files attached


Comment 1

Posted by trouch


Comment 2

Posted by trouch

I agree the REST API is not RESTfull But I cannot guarantee to integrate all your proposals.


Comment 3

Posted by trouch


Comment 4

Posted by trouch


Comment 5

Posted by trouch


Comment 6

Posted by mmackes

Macros that support a "HTTP GET" would help me in my integration of my WebIOPi project and OpenHAB. In OpenHAB connecting an item via a http binding can be done with "HTTP POST" but if you want to have the state of your item updated automatically that needs to happen via a "HTTP GET". For now I have hacked the rest.py file to support my needs until this change is implemented. Thanks.