Changes

Jump to navigation Jump to search
148 bytes added ,  18:47, 16 July 2013
no edit summary
};</pre>
If the URI http://localhost:8984/hello/world is accessed, the result will be kind ofsimilar to:
<pre class="brush:xml">
&lt;response>&gt; &lt;title>&gt;Hello worldWorld!&lt;/title>&gt; &lt;info>You requested this page with Mozilla/5.0 (Windows; Utime&gt; Windows NT 5The current time is: 18:42:02.1306+02:00&lt; en-US) AppleWebKit/525.13 (KHTML, like Gecko) Chrome/0.2.149.27 Safari/525.13.time&ltgt;/info>&lt;/response>&gt;
</pre>
We added The RESTXQ module contains yet another method within that modulefunction:
<pre class="brush:xquery">
declare %rest:path("/form/") %rest:POST %rest:form-param("contentmessage","{$message}", "'(no message delivered')") %rest:header-param("User-Agent", "{$agent}") function page:hello-postman( $message as xs:string, $agent as xs:string*) as element(response) { &lt;response>type='form'&gt; &lt;title>Hello!message&gt;{ $message }&lt;/title>message&gt; &lt;info>It seems you posted a message: user-agent&gt;{ $message agent }&lt;/info>user-agent&gt; &lt;/response>&gt;
};
</pre>
If you posted post something (e.g. using curl or the embedded form at http://localhost:8984/ )... 
<pre class="brush:shell">
curl -i -X POST --data "content='Here comes the postCONTENT'" http://admin:admin@localhost:8984/form
</pre>
You would recieve...you will receive something similar to the following result: 
<pre class="brush:xml">
&lt;response>type="form"&gt; &lt;title>Hello!message&gt;CONTENT&lt;/title>message&gt; &lt;info>It seems you posted a message: 'Here comes the post'user-agent&gt;Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML like Gecko) Chrome/28.0.1500.72 Safari/537.36&lt;/info>user-agent&gt;&lt;/response>&gt;
</pre>
Bureaucrats, editor, reviewer, Administrators
13,550

edits

Navigation menu