<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Misterdom's World &#187; REST</title>
	<atom:link href="http://www.guinard.org/~misterdom/tag/rest/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.guinard.org/~misterdom</link>
	<description>My Computing Logbook</description>
	<lastBuildDate>Sat, 24 Dec 2011 09:31:38 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Doing PUT DELETE and Other Niceties with GWT</title>
		<link>http://www.guinard.org/~misterdom/2009/10/01/doing-put-with-gwt/</link>
		<comments>http://www.guinard.org/~misterdom/2009/10/01/doing-put-with-gwt/#comments</comments>
		<pubDate>Thu, 01 Oct 2009 15:33:35 +0000</pubDate>
		<dc:creator>misterdom</dc:creator>
				<category><![CDATA[Google Web Toolkit (GWT)]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[REST]]></category>
		<category><![CDATA[gwt]]></category>
		<category><![CDATA[HTTP]]></category>
		<category><![CDATA[POST]]></category>
		<category><![CDATA[PUT]]></category>
		<category><![CDATA[verbs]]></category>

		<guid isPermaLink="false">http://www.guinard.org/~misterdom/?p=112</guid>
		<description><![CDATA[You probably are REST lovers like I personally am.
Thus you were probably quite frustrated when seeing that a GWT (Google Web Toolkit) client cannot send other requests than POST or GET.
Well here is the solution:
public class RequestBuilderForAnyHTTPMethodTypeExample extends RequestBuilder {
  /**
   * Constructor that allows a developer to override the HTTP method
 [...]]]></description>
			<content:encoded><![CDATA[<p>You probably are REST lovers like I <a href="http://www.webofthings.com/tag/rest/">personally am</a>.</p>
<p>Thus you were probably quite frustrated when seeing that a GWT (Google Web Toolkit) client cannot send other requests than POST or GET.<br />
Well here is the solution:</p>
<p><code>public class RequestBuilderForAnyHTTPMethodTypeExample extends RequestBuilder {</p>
<p>  /**<br />
   * Constructor that allows a developer to override the HTTP method<br />
   * restrictions imposed by the RequestBuilder class.  Note if you override the<br />
   * RequestBuilder's HTTP method restrictions in this manner, your application<br />
   * may not work correctly on Safari browsers.<br />
   *<br />
   * @param httpMethod any non-null, non-empty string is considered valid<br />
   * @param url any non-null, non-empty string is considered valid<br />
   *<br />
   * @throws IllegalArgumentException if httpMethod or url are empty<br />
   * @throws NullPointerException if httpMethod or url are null<br />
   */<br />
  public RequestBuilderForAnyHTTPMethodTypeExample(String httpMethod, String url) {<br />
    super(httpMethod, url);<br />
  }<br />
</code></p>
<p>i.e. simply subclass the <code>RequestBuilder</code></p>
<p>Source: <a href="http://google-web-toolkit.googlecode.com/svn/javadoc/1.6/com/google/gwt/http/client/package-summary.html"> (see the bottom of the page).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.guinard.org/~misterdom/2009/10/01/doing-put-with-gwt/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JSON and the Quoted Strings</title>
		<link>http://www.guinard.org/~misterdom/2009/09/16/json-and-the-quoted-strings/</link>
		<comments>http://www.guinard.org/~misterdom/2009/09/16/json-and-the-quoted-strings/#comments</comments>
		<pubDate>Wed, 16 Sep 2009 16:50:38 +0000</pubDate>
		<dc:creator>misterdom</dc:creator>
				<category><![CDATA[Dev Logbook]]></category>
		<category><![CDATA[Google Web Toolkit (GWT)]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[gwt]]></category>
		<category><![CDATA[JSON]]></category>
		<category><![CDATA[REST]]></category>

		<guid isPermaLink="false">http://www.guinard.org/~misterdom/?p=103</guid>
		<description><![CDATA[&#8220;Bug&#8221; number two for today is a little more tricky.
I was retrieving a JSON object in the GWT (Google Web Toolkit) and putting its Java representation in a HashMap. The only problem is that I could never find it again by referring to its key which I also extracted from JSON object. Here is why:

currentCons.get("URI").isString().toString()

Is [...]]]></description>
			<content:encoded><![CDATA[<p>&#8220;Bug&#8221; number two for today is a little more tricky.</p>
<p>I was retrieving a JSON object in the <a href="../../../../category/loogbook/google-web-toolkit-gwt/">GWT (Google Web Toolkit)</a> and putting its Java representation in a <code>HashMap</code>. The only problem is that I could never find it again by referring to its key which I also extracted from JSON object. Here is why:</p>
<blockquote><p>
<code>currentCons.get("URI").isString().toString()</code>
</p></blockquote>
<p>Is actually not returning the String representation of a JSONString object but the quoted representation of that String: e.g. &#8220;key&#8221; and not key. It was in the API but it took me a while to figure it out&#8230;</p>
<p>The solution is:</p>
<blockquote><p>
<code>currentCons.get("URI").isString().stringValue();</code>
</p></blockquote>
<p>Which gets what I wanted, i.e. the String representation without the quotes.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.guinard.org/~misterdom/2009/09/16/json-and-the-quoted-strings/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Giving some REST to your C++ code: embedding the SHTTPD server.</title>
		<link>http://www.guinard.org/~misterdom/2008/10/27/giving-some-rest-to-your-c-code-embedding-the-shttp-server/</link>
		<comments>http://www.guinard.org/~misterdom/2008/10/27/giving-some-rest-to-your-c-code-embedding-the-shttp-server/#comments</comments>
		<pubDate>Mon, 27 Oct 2008 14:28:33 +0000</pubDate>
		<dc:creator>misterdom</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[Dev Logbook]]></category>
		<category><![CDATA[Plogg and Smart Meters]]></category>
		<category><![CDATA[Visual Studio .Net]]></category>
		<category><![CDATA[HTTP]]></category>
		<category><![CDATA[REST]]></category>
		<category><![CDATA[visualstudio]]></category>
		<category><![CDATA[webserver]]></category>

		<guid isPermaLink="false">http://www.guinard.org/~misterdom/?p=21</guid>
		<description><![CDATA[Wanting to turn the Ploggs, into more RESTful devices, I needed to add a web server (HTTP) to the C++ code managing the Ploggs.
After comparing and trying a number of lightweight web servers (Apache was not an option for this kind of small app) I picked SHTTPD, mainly because:

 It was one of the few [...]]]></description>
			<content:encoded><![CDATA[<p>Wanting to turn the <a href="?cat=4">Ploggs</a>, into more RESTful devices, I needed to add a web server (HTTP) to the C++ code managing the Ploggs.</p>
<p>After comparing and trying a number of lightweight web servers (Apache was not an option for this kind of small app) I picked <a href="http://shttpd.sourceforge.net/">SHTTPD</a>, mainly because:</p>
<ol>
<li> It was one of the few I managed to embed in my C++ code (I&#8217;m not a C expert&#8230;)</li>
<li> It offered the possibility of registering call back methods when a particular URL is called, which makes it a quite good candidate for a REST interface.</li>
</ol>
<p>Here is how I did proceed to integrate it to my Microsoft Visual C++ project:</p>
<ol>
<li>Compile the project (the core, not the example), this should create a <code>shttpd.lib</code> file. (<a href="?p=17">This post might in case you do not succeed this step </a>).</li>
<li>Copy the shttpd.lib, shttpd.h to your src folder (the one of your Visual Studio project).</li>
<li>Download <a href="http://shttpd.sourceforge.net/shttpd.pem">shttpd.pem</a> and copy it to your src folder as well.</li>
<li>Add the <code>shttpd.h</code> file to your project.</li>
<li>Add the following lib references to your project: <code>shttpd.lib ws2_32.lib</code>, see <a href="?p=15">to get details on how to add it.</a></li>
<li>Add the code to start and setup the server. Snippets can be found in the example folder of the SHTTPD distrib. That in my case:</li>
</ol>
<p><code><br />
// TestSHTTPD.cpp : Defines the entry point for the console application.<br />
#include<br />
#include<br />
#include<br />
#include<br />
#include </code></p>
<p>#include &#8220;stdafx.h&#8221;<br />
#include &#8220;shttpd.h&#8221;</p>
<p>#define ALIAS_URI &#8220;/my_c&#8221;<br />
#define ALIAS_DIR &#8220;c:\\&#8221;</p>
<p>static void show_index(struct shttpd_arg *arg) {<br />
shttpd_printf(arg, &#8220;%s&#8221;,<br />
&#8220;HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n&#8221;<br />
&#8220;Welcome to embedded example of SHTTPD&#8221;);<br />
arg-&gt;flags |= SHTTPD_END_OF_OUTPUT;<br />
}</p>
<p>int _tmain(int argc, char* argv[])<br />
{<br />
/*<br />
* Initialize SHTTPD context.<br />
* Attach folder c:\ to the URL /my_c  (for windows), and<br />
* /etc/ to URL /my_etc (for UNIX). These are Apache-like aliases.<br />
* Set WWW root to current directory.<br />
* Start listening on ports 8080 and 8081<br />
*/<br />
int	data = 1234567;<br />
struct shttpd_ctx	*ctx;<br />
ctx = shttpd_init(argc, argv);<br />
shttpd_set_option(ctx, &#8220;ssl_cert&#8221;, &#8220;shttpd.pem&#8221;);<br />
shttpd_set_option(ctx, &#8220;aliases&#8221;, ALIAS_URI &#8220;=&#8221; ALIAS_DIR);<br />
shttpd_set_option(ctx, &#8220;ports&#8221;, &#8220;8080,8081s&#8221;);</p>
<p>/* Register an index page under two URIs */<br />
shttpd_register_uri(ctx, &#8220;/&#8221;, &amp;show_index, (void *) &amp;data);<br />
shttpd_register_uri(ctx, &#8220;/abc.html&#8221;, &amp;show_index, (void *) &amp;data);</p>
<p>/* Serve connections infinitely until someone kills us */<br />
for (;;)<br />
shttpd_poll(ctx, 1000);</p>
<p>/* Probably unreached, because we will be killed by a signal */<br />
shttpd_fini(ctx);</p>
<p>return 0;<br />
}</p>
<p>You should now be able to use the web server within your application.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.guinard.org/~misterdom/2008/10/27/giving-some-rest-to-your-c-code-embedding-the-shttp-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

