CrawfordWCR / clickframes

Automatically exported from code.google.com/p/clickframes
0 stars 0 forks source link

Support definition of RESTful services #12

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
The designer of a webapp may wish to define RESTful services within his appspec.

Conceptually, this would be like <action>s outside of <page>s, only with 
<param>s inside the the <action>.

I don't care what we call the element in the end, but for the time being, let's 
say it's <service>. To make it more reflective of REST, we ought to distinguish 
between HTTP methods (get, post, put, delete).

e.g.

<appspec>
  ...
  <services>
    <service id="recipe">
      <method type="get">
        <params>
          <param id="recipeId">
             <!-- normal content, including entityPropertyRef -->
          </param>
        </params>
        <returns>
          <entityRef entity="recipe" />
        </returns>
      </get>
      <method type="post">
        <params>
          <param id="recipe">
            <entityRef entity="recipe" format="json" />
          </param>
        </params>
        <returns>
          <entityPropertyRef entity="recipe" property="recipeId" />
        </returns>
      </method>
    </service>
  </services>
</appspec>

BTW, I'm not fond of using <param> to define an entity to post... might be 
overloading the <param> element too much.

Original issue reported on code.google.com by jonathan...@gtempaccount.com on 2 Sep 2010 at 1:42

GoogleCodeExporter commented 9 years ago

Original comment by jonathan...@gtempaccount.com on 2 Sep 2010 at 1:42

GoogleCodeExporter commented 9 years ago
Does a "get" service roughly equivalent to an invisible page which performs an 
action and then redirects to a view?

Original comment by vineet.manohar@gmail.com on 2 Sep 2010 at 2:14

GoogleCodeExporter commented 9 years ago
See 
http://en.wikipedia.org/wiki/Representational_State_Transfer#RESTful_web_service
s

get = read (take params, read entity from database, return data)
put = create (take data and create new entity in database, return id)
post = update (take params, take data, and update existing entity in database)
delete = delete (take params, delete entity from database)

In all cases "data" could be XML, JSON, etc.

Original comment by jonathan...@gtempaccount.com on 2 Sep 2010 at 3:14

GoogleCodeExporter commented 9 years ago
Reduced priority. 

Original comment by vineet.manohar@gmail.com on 15 Oct 2010 at 2:53