Re: REST API for SWI-Prolog

Jan Wielemaker <[email protected]>
Newsgroups gmane.comp.ai.prolog.swi
Message-ID <[email protected]>
On 07/14/2013 01:52 PM, Wouter Beek wrote:
> Hi all,
> 
> Yesterday I wanted to implement a RESTfull Web service and wanted to use
> SWI-Prolog for that (since it has a very nice HTTP library).
> 
> I found out that the support for REST is not complete. Only the GET and
> POST methods of the HTTP 1.1 specification seem to be fully supported (but
> not DELETE,  PUT, ...).
> 
> For instance http_parameters/[2,3] has extensive support for the POST
> method, but only uses the search terms for other HTTP methods. This seems
> to be intentional since the related documentation section is called: "3.9
> Get parameters from HTML forms". Form submission uses GET/POST, however
> forms are not the only / most important way of sending HTTP requests in a
> modern Ajax environment.
> 
> So my questions are:
> - Was I looking in the work spot? / Are there other libraries, etc.?

A little.  http_parameters/3 can indeed only deal with GET requests and
POST requests that post www-form-encoded data.  But, the underlying
http_read_data/3 can deal with a lot more and can be extended with
plugins that react on the Content-type.  If you know the format of
data you want to have, you can also call specific routines such as
http_read_json/3, or the XML/HTML/... parsers.

> - Does anybody have experience with Ajax and/or REST programming in
> SWI-Prolog and is s/he willing to interchange ideas and/or code?

I think there is some of this in SWAPP (git at www.swi-prolog.org).

> - Would it be a worthwhile effort to extend the existing HTTP library?

I think it is mainly a matter of improving the documentation.  Both
server and client APIs have no problem handling the full REST set of
actions (AFAIK).  Nice challenge to use the new editing and tagging
facilities ...

	Cheers --- Jan
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.