<div dir="ltr"><div dir="ltr">On Tue, Jun 7, 2011 at 17:49, <span dir="ltr"><<a href="mailto:michael.vancanneyt@wisa.be">michael.vancanneyt@wisa.be</a>></span> wrote:</div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im"><br>
<br>
On Tue, 7 Jun 2011, Ludo Brands wrote:<br>
<br>
</div><div class="im"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Ok, that is simply an alternative to the current<br>
TFPWebDataModule which does<br>
not rely on part of the URL to determine the CRUD action, but<br>
uses the URL<br>
just to determine the resource, and the HTTP method to see<br>
which CRUD action<br>
needs to be performed.<br>
<br>
That's easily done. It's about 5 lines of code in<br>
TFPWebDataModule: 1 for a "RESTFul" property, 4 to determine<br>
the action from the method if RESTFul is set to True.<br>
<br>
Do you think this would be a useful addition ?<br>
<br>
</blockquote>
<br>
That would indeed be a very good starting point for a REST implementation.<br>
In the few REST implementations I have seen, the uri is used to pass on the<br>
record identifier for the RUD action while, if I understand correctly,<br>
TFPWebDataModule gets the record identifier together with the data from a<br>
datainputadaptor. This will probaly need a customised datainputadaptor since<br>
a record identifier can be anything.<br>
</blockquote>
<br></div>
Indeed. In fact, the implementation should go in the web input adaptor.<br></blockquote><div><br></div><div>To be "RESTful" (I'm talking about HTTP), you do not pass the parameters of "GET,DELTE" etc.. as a parameter, but as part of the HTTP Protocol, that is:</div>
<div><br></div><div>GET /names HTTP/1.1</div><div>....</div><div><br></div><div><br></div><div>DELETE /names HTTP/1.1</div><div>....</div><div><br></div><div>etc...</div><div><br></div><div><br></div><div><meta http-equiv="content-type" content="text/html; charset=utf-8"><span class="Apple-style-span" style="border-collapse: collapse; font-family: arial, sans-serif; font-size: 13px; "><div class="im" style="color: rgb(80, 0, 80); ">
<br><br><blockquote class="gmail_quote" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex; ">
As you know REST is an architecture, not just a set of classes or methods.<br>REST doesn't even require HTTP. So calling a webserver class RESTsomething<br>because onGet, onPut, etc. are exposed does not have any added value.<br>
</blockquote><br></div>>I agree. This was why I didn't understand the original poster's question; the<br>>implementation is trivial.</span></div><div><span class="Apple-style-span" style="border-collapse: collapse; font-family: arial, sans-serif; font-size: 13px; "><br>
</span></div><div><span class="Apple-style-span" style="border-collapse: collapse; font-family: arial, sans-serif; font-size: 13px; ">At the moment we are talking about HTTP, so TFPREST... for HTTP CGI is actually in order.</span></div>
<div><font class="Apple-style-span" face="arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse;">The issue is not about writing 10 lines of code each time you need to separate GET from PUT, but the fact that you repeat yourself 10 lines of code on each location you require to this separation.</span></font></div>
<div><font class="Apple-style-span" face="arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse; "><br></span></font></div><div><font class="Apple-style-span" face="arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse;">I'm using such work for example in <a href="http://www.sinatrarb.com/">Sinatra</a>. I have an API for having recordings after few of my applications (Asterisk based) finished working. so you do the following:</span></font></div>
<div><font class="Apple-style-span" face="arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse;"><br></span></font></div><div><font class="Apple-style-span" face="arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse;">GET /recording/filename HTTP/1.1</span></font></div>
<div><font class="Apple-style-span" face="arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse;">.......</span></font></div><div><font class="Apple-style-span" face="arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse;"> </span></font></div>
<div><font class="Apple-style-span" face="arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse;">DELETE /</span></font><span class="Apple-style-span" style="border-collapse: collapse; font-family: arial, sans-serif; ">recording/filename HTTP/1.1</span></div>
<meta http-equiv="content-type" content="text/html; charset=utf-8"><div><font class="Apple-style-span" face="arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse; ">.......</span></font></div>
<div><br></div><div>So you can download the recording (if exists) and delete it when no longer need it.</div><div>If I require to implement the same thing on fpWeb, it actually takes more code because there is no separation of any kind.</div>
<div><br></div><div>At the moment I wish to create a CRUD engine in fpWeb (and keep it open source) that had a layer above databases, so you do not provide direct access to the database, but you provide access to the data, like a Proxy, but in HTTP, so instead of using SQL (for example) you use JSON, and instead of using Pg, Fb, MySQL, SQLite etc... it is agnostic, and you control what user can do what type of access and action etc... </div>
<div><br></div><div>Sure you can do so at the moment ,but you will repeat your code or write way too general code for something like that. Having OnGet etc... provide easier way not to repeat yourself and even making the code much more readable and maintainable imho.</div>
<div><br></div><div>I Hope that is more clearer now.</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br>
<br>
Michael.</blockquote><div><br></div><div>Ido</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div><div></div><div class="h5"><br>
_______________________________________________<br>
fpc-pascal maillist - <a href="mailto:fpc-pascal@lists.freepascal.org" target="_blank">fpc-pascal@lists.freepascal.org</a><br>
<a href="http://lists.freepascal.org/mailman/listinfo/fpc-pascal" target="_blank">http://lists.freepascal.org/mailman/listinfo/fpc-pascal</a><br>
</div></div></blockquote></div><br></div>