<br><br><div class="gmail_quote">On Sun, Jul 11, 2010 at 2:23 PM, Christoph Baudson <span dir="ltr"><<a href="mailto:christoph@baudson.de">christoph@baudson.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div class="im">-----BEGIN PGP SIGNED MESSAGE-----<br>
Hash: SHA1<br>
<br>
</div><div class="im">Vikas Banjara wrote:<br>
> Thanks Christoph and Siddharth for prompt reply.<br>
><br>
> But I have a different cocern. For either format, all the requests from<br>
> client will be handled by one script. I went throgh Christoph's article:<br>
> <a href="http://baudson.cute-ice.de/serendipity/index.php?/archives/20-RESTful-Web-Service-with-PHP-2.html" target="_blank">http://baudson.cute-ice.de/serendipity/index.php?/archives/20-RESTful-Web-Service-with-PHP-2.html</a><br>
><br>
> Here, Christoph is parsing the URL to identify the resource. So this means<br>
> that all the URLs are being handled by the same script. I can explain it in<br>
> verbose.<br>
><br>
> Client sends: GET api/user/id/json<br>
> Now in general apache server will try to open a page<br>
> api/user/id/json/index.html or execute the file api/user/id/json.php<br>
> But we know this is wrong. Actually, there will be a script say<br>
> api/index.php which will parse the URL api/user/id/json and find the<br>
> resource and format.<br>
><br>
> So, one way to solve this problem is to map all the urls of the form api/*<br>
> to api/index.php. This can be done by using mod rewrite.<br>
> Any other solution? Do I make sense? Normally I don't :-)<br>
<br>
</div>You can have a single script for each resource type in the approach I<br>
mentioned. Think of it like this<br>
<br>
api/users.php/json<br>
<div class="im">api/user.php/<id>/json<br>
</div>api/wms.php/<id>/json><br>
<br>
etc.<br>
<br></blockquote><div><br>Even if it is api/users.php/json<br>when the client will send a request GET api/users/json , the server will look for api/users/json/index.php or api/users/json/index.html<br><br> </div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
So you won't need any rewriting.<br>
<br>
Christoph<br>
<div class="im"><br>
<br>
<br>
><br>
> Regards<br>
> Vikas<br>
><br>
> On Sun, Jul 11, 2010 at 1:04 PM, Siddharth Prakash Singh<br>
> <<a href="mailto:spsneo@gmail.com">spsneo@gmail.com</a>>wrote:<br>
><br>
>> Hi Christoph,<br>
>><br>
>> Twitter uses the format like GET user/id.json or GET user/id.xml<br>
>><br>
>> Siddharth<br>
>><br>
>> On Sun, Jul 11, 2010 at 12:54 PM, Christoph Baudson<br>
>> <<a href="mailto:christoph@baudson.de">christoph@baudson.de</a>> wrote:<br>
</div><div><div></div><div class="h5">> Hi Vikas,<br>
><br>
> Vikas Banjara wrote:<br>
>>>>> Hi all,<br>
>>>>><br>
>>>>> I want a discussion on ways of handling REST API Request. Rest request<br>
>>> URL<br>
>>>>> will be like -<br>
>>>>> GET api/user/id.json or Get api/user/id.xml<br>
>>>>> Now all the requests are handled by one page say api/index.php. So how<br>
>>> are<br>
>>>>> we going to redirect all such request to this index.php.<br>
>>>>> One solution could be Apache rewrite.<br>
>>>>><br>
>>>>> Is it a good solution? Is it a standard solution? Any other better<br>
>>> solution?<br>
> I had studied a book [1] on RESTful Web Services with PHP last year. The<br>
> authors used the following style of representing resources<br>
><br>
> api/user.php/<id>/json<br>
><br>
> Not sure if this is the standard way, but I think it's easier to start<br>
> without rewrite rules (more people will join and test).<br>
><br>
> Read more about it at my blog [2].<br>
><br>
> Comments?<br>
><br>
> Christoph<br>
><br>
> [1] <a href="http://www.packtpub.com/restful-php-web-services/book" target="_blank">http://www.packtpub.com/restful-php-web-services/book</a><br>
> [2]<br>
><br>
>>> <a href="http://baudson.cute-ice.de/serendipity/index.php?/archives/19-RESTful-Web-Service-with-PHP-1.html" target="_blank">http://baudson.cute-ice.de/serendipity/index.php?/archives/19-RESTful-Web-Service-with-PHP-1.html</a><br>
><br>
>>>>> Thanks<br>
>>>>> Vikas<br>
>>>>><br>
>>>>><br>
>>>>><br>
>>>>> ------------------------------------------------------------------------<br>
>>>>><br>
>>>>> _______________________________________________<br>
>>>>> Mapbender_dev mailing list<br>
>>>>> <a href="mailto:Mapbender_dev@lists.osgeo.org">Mapbender_dev@lists.osgeo.org</a><br>
>>>>> <a href="http://lists.osgeo.org/mailman/listinfo/mapbender_dev" target="_blank">http://lists.osgeo.org/mailman/listinfo/mapbender_dev</a><br>
</div></div><div class="im">_______________________________________________<br>
Mapbender_dev mailing list<br>
<a href="mailto:Mapbender_dev@lists.osgeo.org">Mapbender_dev@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/mapbender_dev" target="_blank">http://lists.osgeo.org/mailman/listinfo/mapbender_dev</a><br>
>>><br>
>><br>
>><br>
>> --<br>
>> Siddharth Prakash Singh<br>
>> <a href="http://www.spsneo.com" target="_blank">http://www.spsneo.com</a><br>
>> _______________________________________________<br>
>> Mapbender_dev mailing list<br>
>> <a href="mailto:Mapbender_dev@lists.osgeo.org">Mapbender_dev@lists.osgeo.org</a><br>
>> <a href="http://lists.osgeo.org/mailman/listinfo/mapbender_dev" target="_blank">http://lists.osgeo.org/mailman/listinfo/mapbender_dev</a><br>
>><br>
<br>
</div><div class="im">> ------------------------------------------------------------------------<br>
<br>
> _______________________________________________<br>
> Mapbender_dev mailing list<br>
> <a href="mailto:Mapbender_dev@lists.osgeo.org">Mapbender_dev@lists.osgeo.org</a><br>
> <a href="http://lists.osgeo.org/mailman/listinfo/mapbender_dev" target="_blank">http://lists.osgeo.org/mailman/listinfo/mapbender_dev</a><br>
<br>
-----BEGIN PGP SIGNATURE-----<br>
Version: GnuPG v1.4.9 (GNU/Linux)<br>
Comment: Using GnuPG with Mozilla - <a href="http://enigmail.mozdev.org" target="_blank">http://enigmail.mozdev.org</a><br>
<br>
</div>iEYEARECAAYFAkw5hpMACgkQGtMIfbycMX5daACgzrUR02TkzzWZIt6L3WDJb190<br>
FWwAn2IAhmNrKSwDAJyet2AUcapC7o8h<br>
=r/bB<br>
<div><div></div><div class="h5">-----END PGP SIGNATURE-----<br>
_______________________________________________<br>
Mapbender_dev mailing list<br>
<a href="mailto:Mapbender_dev@lists.osgeo.org">Mapbender_dev@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/mapbender_dev" target="_blank">http://lists.osgeo.org/mailman/listinfo/mapbender_dev</a><br>
</div></div></blockquote></div><br>