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