<div dir="ltr">I finally have a set of HTTP CRUD operations working using the WebClient package!<div>The following is a method that handles requests for all URLs with the path "/dog".<br></div><div>Regardless of the HTTP method, all requests pass through this.</div><div>This code works perfectly, but I'm questioning whether it is idiomatic Smalltalk code.</div><div>What would you do differently in this code?</div><div><br></div><div><div><font face="monospace">handleDog: aRequest  <br>    "handle an HTTP request based on its method"<br></font><span style="font-family:monospace">   <span class="gmail-Apple-converted-space"> </span></span><font face="monospace">| id parts |<br>       <br></font><span style="font-family:monospace">   <span class="gmail-Apple-converted-space"> </span></span><font face="monospace">aRequest method = 'GET' ifTrue: [<br></font><span style="font-family:monospace">   <span class="gmail-Apple-converted-space"> </span></span><span style="font-family:monospace">   </span><span class="gmail-Apple-converted-space" style="font-family:monospace"> </span><span style="font-family:monospace">| accept |</span></div><div><font face="monospace"><br></font><span style="font-family:monospace">   <span class="gmail-Apple-converted-space"> </span></span><span style="font-family:monospace">   </span><span class="gmail-Apple-converted-space" style="font-family:monospace"> </span><span style="font-family:monospace">accept := aRequest headerAt: 'Accept'.</span></div><div><span style="font-family:monospace">   </span><span class="gmail-Apple-converted-space" style="font-family:monospace"> </span><span style="font-family:monospace">   </span><span class="gmail-Apple-converted-space" style="font-family:monospace"> </span><span style="font-family:monospace">(accept includesSubString: 'application/json') ifTrue: [</span></div><div><span style="font-family:monospace">   </span><span class="gmail-Apple-converted-space" style="font-family:monospace"> </span><span style="font-family:monospace">   </span><span class="gmail-Apple-converted-space" style="font-family:monospace"> </span><span style="font-family:monospace">   </span><span class="gmail-Apple-converted-space" style="font-family:monospace"> </span><span style="font-family:monospace">self getDogsAsJson: aRequest.</span></div><div><span style="font-family:monospace">   </span><span class="gmail-Apple-converted-space" style="font-family:monospace"> </span><span style="font-family:monospace">   </span><span class="gmail-Apple-converted-space" style="font-family:monospace"> </span><span style="font-family:monospace">   </span><span class="gmail-Apple-converted-space" style="font-family:monospace"> </span><span style="font-family:monospace">^nil</span></div><div><span style="font-family:monospace">   </span><span class="gmail-Apple-converted-space" style="font-family:monospace"> </span><span style="font-family:monospace">   </span><span class="gmail-Apple-converted-space" style="font-family:monospace"> </span><span style="font-family:monospace">].</span></div><div><span style="font-family:monospace"><br></span></div><div><span style="font-family:monospace">   </span><span class="gmail-Apple-converted-space" style="font-family:monospace"> </span><span style="font-family:monospace">   </span><span class="gmail-Apple-converted-space" style="font-family:monospace"> </span><span style="font-family:monospace">(</span>accept<span style="font-family:monospace"> includesSubString: 'text/html') ifTrue: [</span></div><div><span style="font-family:monospace">   </span><span class="gmail-Apple-converted-space" style="font-family:monospace"> </span><span style="font-family:monospace">   </span><span class="gmail-Apple-converted-space" style="font-family:monospace"> </span><span style="font-family:monospace">   </span><span class="gmail-Apple-converted-space" style="font-family:monospace"> </span><span style="font-family:monospace">self getDogsAsHtml: aRequest.</span></div><div><span style="font-family:monospace">   </span><span class="gmail-Apple-converted-space" style="font-family:monospace"> </span><span style="font-family:monospace">   </span><span class="gmail-Apple-converted-space" style="font-family:monospace"> </span><span style="font-family:monospace">   </span><span class="gmail-Apple-converted-space" style="font-family:monospace"> </span><span style="font-family:monospace">^nil</span></div><div><span style="font-family:monospace">   </span><span class="gmail-Apple-converted-space" style="font-family:monospace"> </span><span style="font-family:monospace">   </span><span class="gmail-Apple-converted-space" style="font-family:monospace"> </span><span style="font-family:monospace">]</span></div><div><span style="font-family:monospace">   </span><span class="gmail-Apple-converted-space" style="font-family:monospace"> </span><font face="monospace">].<br><br></font><span style="font-family:monospace">   <span class="gmail-Apple-converted-space"> </span></span><font face="monospace">aRequest method = 'POST' ifTrue: [<br></font><span style="font-family:monospace">   <span class="gmail-Apple-converted-space"> </span></span><span style="font-family:monospace">   </span><span class="gmail-Apple-converted-space" style="font-family:monospace"> </span><span style="font-family:monospace">self createDog: aRequest.</span></div><div><span style="font-family:monospace">   </span><span class="gmail-Apple-converted-space" style="font-family:monospace"> </span><span style="font-family:monospace">   </span><span class="gmail-Apple-converted-space" style="font-family:monospace"> </span><span style="font-family:monospace">^nil</span></div><div><span style="font-family:monospace">   </span><span class="gmail-Apple-converted-space" style="font-family:monospace"> </span><font face="monospace">].<br><br></font><span style="font-family:monospace">   <span class="gmail-Apple-converted-space"> </span></span><font face="monospace">"Get the path parameter value."<br></font><span style="font-family:monospace">   <span class="gmail-Apple-converted-space"> </span></span><span style="font-family:monospace">"TODO: Is this really the best way to do it?"</span></div><div><span style="font-family:monospace">   </span><span class="gmail-Apple-converted-space" style="font-family:monospace"> </span><font face="monospace">parts := aRequest url prefixAndSuffix: $/.<br></font><span style="font-family:monospace">   <span class="gmail-Apple-converted-space"> </span></span><font face="monospace">id := parts last asNumber.<br><br></font><span style="font-family:monospace">   <span class="gmail-Apple-converted-space"> </span></span><font face="monospace">aRequest method = 'DELETE' ifTrue: [<br></font><span style="font-family:monospace">   <span class="gmail-Apple-converted-space"> </span></span><span style="font-family:monospace">   </span><span class="gmail-Apple-converted-space" style="font-family:monospace"> </span><span style="font-family:monospace">self deleteDog: aRequest id: id.</span></div><div><span style="font-family:monospace">   </span><span class="gmail-Apple-converted-space" style="font-family:monospace"> </span><span style="font-family:monospace">   </span><span class="gmail-Apple-converted-space" style="font-family:monospace"> </span><span style="font-family:monospace">^nil</span></div><div><span style="font-family:monospace">   </span><span class="gmail-Apple-converted-space" style="font-family:monospace"> </span><font face="monospace">].<br><br></font><span style="font-family:monospace">   <span class="gmail-Apple-converted-space"> </span></span><font face="monospace">aRequest method = 'PUT' ifTrue: [<br></font><span style="font-family:monospace">   <span class="gmail-Apple-converted-space"> </span></span><span style="font-family:monospace">   </span><span class="gmail-Apple-converted-space" style="font-family:monospace"> </span><span style="font-family:monospace">self updateDog: aRequest id: id.</span></div><div><span style="font-family:monospace">   </span><span class="gmail-Apple-converted-space" style="font-family:monospace"> </span><span style="font-family:monospace">   </span><span class="gmail-Apple-converted-space" style="font-family:monospace"> </span><span style="font-family:monospace">^nil</span></div><div><span style="font-family:monospace">   </span><span class="gmail-Apple-converted-space" style="font-family:monospace"> </span><font face="monospace">]</font></div><div><font face="monospace"><br></font></div><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div><font face="arial, helvetica, sans-serif">R. Mark Volkmann</font></div><div><span style="font-size:12.8000001907349px"><font face="arial, helvetica, sans-serif">Object Computing, Inc.</font></span></div></div></div></div></div></div></div></div></div></div>