summaryrefslogtreecommitdiffstats
path: root/_build/static/archives/extend/attachments/20130517/629071b8/attachment.html
blob: 5eb70a362a86433bab1b0fbbb408fefe1371f150 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<tt>
&lt;span&nbsp;style=&quot;color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)&quot;&gt;Hi&nbsp;all,�&lt;/span&gt;&lt;div&nbsp;style=&quot;color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)&quot;&gt;<br>
&lt;br&gt;&lt;/div&gt;&lt;div&nbsp;style=&quot;color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)&quot;&gt;I&nbsp;am&nbsp;learning&nbsp;cowboy&nbsp;by&nbsp;building&nbsp;a&nbsp;small&nbsp;application&nbsp;with&nbsp;rest&nbsp;interface.�&lt;/div&gt;&lt;div&nbsp;style=&quot;color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)&quot;&gt;<br>
I&nbsp;have&nbsp;a&nbsp;hello_world&nbsp;rest&nbsp;handler&nbsp;and&nbsp;I&nbsp;want&nbsp;to&nbsp;implement&nbsp;POST&nbsp;method&nbsp;that&nbsp;returns&nbsp;&lt;/div&gt;&lt;div&nbsp;style=&quot;color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)&quot;&gt;json&nbsp;as&nbsp;response&nbsp;to&nbsp;a&nbsp;client.&nbsp;Therefor&nbsp;I&nbsp;implemented&nbsp;�callbacks&nbsp;allowed_methods,�&lt;/div&gt;<br>
&lt;div&nbsp;style=&quot;color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)&quot;&gt;content_types_accepted&nbsp;and&nbsp;hello_json.&nbsp;The&nbsp;docu&nbsp;says&nbsp;user&nbsp;callbacks&nbsp;can�&lt;/div&gt;&lt;div&nbsp;style=&quot;color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)&quot;&gt;<br>
return&nbsp;{Value,&nbsp;Req,&nbsp;State}&nbsp;and&nbsp;also&nbsp;can&nbsp;return&nbsp;{halt,&nbsp;Req,&nbsp;State}.&nbsp;It&nbsp;is&nbsp;not&nbsp;really&nbsp;clear�&lt;/div&gt;&lt;div&nbsp;style=&quot;color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)&quot;&gt;what&nbsp;that&nbsp;Value&nbsp;should&nbsp;be.&nbsp;So&nbsp;I&nbsp;tried&nbsp;{ok,&nbsp;Req,&nbsp;State}&nbsp;and&nbsp;{true,&nbsp;Req,&nbsp;State}&nbsp;and&nbsp;with&lt;/div&gt;<br>
&lt;div&nbsp;style=&quot;color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)&quot;&gt;both&nbsp;values&nbsp;I&nbsp;have�&lt;/div&gt;&lt;div&nbsp;style=&quot;color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)&quot;&gt;<br>
&lt;br&gt;&lt;/div&gt;&lt;div&nbsp;style=&quot;color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)&quot;&gt;&lt;div&gt;=ERROR&nbsp;REPORT====&nbsp;11-May-2013::16:06:40&nbsp;===&lt;/div&gt;&lt;div&gt;Error&nbsp;in&nbsp;process&nbsp;&lt;0.6649.0&gt;&nbsp;with&nbsp;exit&nbsp;value:&nbsp;{function_clause,[{cowboy_req,reply,[303,....&lt;/div&gt;<br>
&lt;/div&gt;&lt;div&nbsp;style=&quot;color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)&quot;&gt;&lt;br&gt;&lt;/div&gt;&lt;div&nbsp;style=&quot;color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)&quot;&gt;<br>
and&nbsp;client&nbsp;gets&nbsp;right&nbsp;response.&nbsp;If&nbsp;I&nbsp;use&nbsp;{halt,&nbsp;Req,&nbsp;State}&nbsp;the&nbsp;client&nbsp;gets&nbsp;right&nbsp;response&nbsp;too&lt;/div&gt;&lt;div&nbsp;style=&quot;color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)&quot;&gt;and&nbsp;there&nbsp;is&nbsp;no&nbsp;errors.&nbsp;So,&nbsp;Is&nbsp;it&nbsp;right&nbsp;way&nbsp;to&nbsp;write&nbsp;a&nbsp;POST&nbsp;callback&nbsp;and&nbsp;what&nbsp;Values&nbsp;can&lt;/div&gt;<br>
&lt;div&nbsp;style=&quot;color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)&quot;&gt;be&nbsp;used&nbsp;for&nbsp;user&nbsp;callbacks?&nbsp;I&nbsp;write&nbsp;my&nbsp;code&nbsp;below.&lt;/div&gt;&lt;div&nbsp;style=&quot;color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)&quot;&gt;<br>
&lt;br&gt;&lt;/div&gt;&lt;div&nbsp;style=&quot;color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)&quot;&gt;amike,�&lt;/div&gt;&lt;div&nbsp;style=&quot;color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)&quot;&gt;<br>
Vitali&lt;/div&gt;&lt;div&nbsp;style=&quot;color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)&quot;&gt;&lt;br&gt;&lt;/div&gt;&lt;div&nbsp;style=&quot;color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)&quot;&gt;<br>
&lt;div&gt;allowed_methods(Req,&nbsp;State)&nbsp;-&gt;&lt;/div&gt;&lt;div&gt;&lt;span&nbsp;style=&quot;white-space:pre-wrap&quot;&gt;&nbsp;&nbsp;&lt;/span&gt;{[&lt;&lt;&quot;POST&quot;&gt;&gt;,&nbsp;&lt;&lt;&quot;DELETE&quot;&gt;&gt;],&nbsp;Req,&nbsp;State}.&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;content_types_accepted(Req,&nbsp;State)&nbsp;-&gt;&lt;/div&gt;<br>
&lt;div&gt;&lt;span&nbsp;style=&quot;white-space:pre-wrap&quot;&gt;&nbsp;&nbsp;&lt;/span&gt;{[&lt;/div&gt;&lt;div&gt;&lt;span&nbsp;style=&quot;white-space:pre-wrap&quot;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/span&gt;��&nbsp;�{{&lt;&lt;&quot;application&quot;&gt;&gt;,&nbsp;&lt;&lt;&quot;x-www-form-urlencoded&quot;&gt;&gt;,&nbsp;[]},&nbsp;hello_json}&lt;/div&gt;<br>
&lt;div&gt;&lt;span&nbsp;style=&quot;white-space:pre-wrap&quot;&gt;&nbsp;&nbsp;&lt;/span&gt;�],�Req,&nbsp;State}.&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;hello_json(Req,&nbsp;State)&nbsp;-&gt;&lt;/div&gt;&lt;div&gt;&lt;span&nbsp;style=&quot;white-space:pre-wrap&quot;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/span&gt;{ok,&nbsp;Req2}&nbsp;=&nbsp;cowboy_req:reply(200,&nbsp;[{&lt;&lt;&quot;content-type&quot;&gt;&gt;,&nbsp;&lt;&lt;&quot;application/json&quot;&gt;&gt;}&nbsp;],&nbsp;&lt;&lt;&quot;{\&quot;rest\&quot;:&nbsp;\&quot;Hello&nbsp;World!\&quot;}&quot;&gt;&gt;,&nbsp;Req),&lt;/div&gt;<br>
&lt;div&gt;&lt;span&nbsp;style=&quot;white-space:pre-wrap&quot;&gt;&nbsp;&nbsp;&lt;/span&gt;{halt,&nbsp;Req2,&nbsp;State}.&lt;/div&gt;&lt;/div&gt;<br>

</tt>