<font size=2 face="sans-serif">&gt;&gt;</font><font size=3> - `HTTPBodyProcessing`
is a very long word with no obvious meaning.</font>
<br>
<br><font size=2 face="sans-serif">Agreed, the naming here could be clearer
as to what its purpose is. Do you have any suggestions?</font>
<br>
<br><font size=2 face="sans-serif">&gt;&gt;</font><font size=3> - I would
use `HTTPResponse` instead of `HTTPResponseWriter` </font>
<br>
<br><font size=2 face="sans-serif">The use of HTTPResponseWriter here is
very deliberate because eventually the API should be symmetrical for the
server and client use cases, ie: a server has access to a HTTPRequest and
a HTTPResponseWriter, and a client has access to a HTTPRequestWriter and
a HTTPResponse.</font>
<br>
<br><font size=2 face="sans-serif">&gt;&gt;</font><font size=3> - I would
rename `writeBody` to `write` (and, maybe, `writeHeader` to `addHeader`,
`setHeader`, `appendHeader` or something similar)</font>
<br>
<br><font size=2 face="sans-serif">I think if we we're to switch to using
&quot;write()&quot; for writeBody(), then we'd have to move to:</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; func
write(headers: HTTPHeaders, status: HTTPResponseStatus, completion: @escaping
(Result) -&gt; Void)</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; func
write(body: UnsafeHTTPResponseBody, completion: @escaping (Result) -&gt;
Void)</font>
<br><font size=2 face="sans-serif">How does that look?</font>
<br>
<br>
<br><font size=2 face="sans-serif">Chris</font>
<br>
<br>
<br>
<br>
<br><font size=1 color=#5f5f5f face="sans-serif">From: &nbsp; &nbsp; &nbsp;
&nbsp;</font><font size=1 face="sans-serif">Georgios Moschovitis
&lt;george.moschovitis@icloud.com&gt;</font>
<br><font size=1 color=#5f5f5f face="sans-serif">To: &nbsp; &nbsp; &nbsp;
&nbsp;</font><font size=1 face="sans-serif">Chris Bailey &lt;BAILEYC@uk.ibm.com&gt;</font>
<br><font size=1 color=#5f5f5f face="sans-serif">Cc: &nbsp; &nbsp; &nbsp;
&nbsp;</font><font size=1 face="sans-serif">swift-server-dev@swift.org</font>
<br><font size=1 color=#5f5f5f face="sans-serif">Date: &nbsp; &nbsp; &nbsp;
&nbsp;</font><font size=1 face="sans-serif">04/09/2017 20:26</font>
<br><font size=1 color=#5f5f5f face="sans-serif">Subject: &nbsp; &nbsp;
&nbsp; &nbsp;</font><font size=1 face="sans-serif">Re: [swift-server-dev]
HTTP API Review</font>
<br>
<hr noshade>
<br>
<br>
<br><font size=3>Also, </font>
<br>
<br><font size=3>- `HTTPBodyProcessing` is a very long word with no obvious
meaning.</font>
<br><font size=3>- I would use `HTTPResponse` instead of `HTTPResponseWriter`
</font>
<br><font size=3>- I would rename `writeBody` to `write` (and, maybe, `writeHeader`
to `addHeader`, `setHeader`, `appendHeader` or something similar)</font>
<br>
<br><font size=3>-g.</font>
<br>
<br><font size=3>On 3 Sep 2017, at 8:51 PM, Chris Bailey &lt;</font><a href=mailto:BAILEYC@uk.ibm.com><font size=3 color=blue><u>BAILEYC@uk.ibm.com</u></font></a><font size=3>&gt;
wrote:</font>
<br>
<br><font size=2 face="sans-serif">Hi Georgios:</font><font size=3> <br>
</font><font size=2 face="sans-serif"><br>
The protocol which the class needs to implement is 'HTTPRequestHandling'
but the class can have any name the user wants to use. I agree that for
the documentation (and the tests!) the use of 'Handler' is confusing and
could be better. How does the following look as a sample &quot;Hello World&quot;
app?</font><font size=3> <br>
</font><font size=2 face="Courier New"><br>
import HTTP</font><font size=3> <br>
</font><font size=2 face="Courier New"><br>
class MyServer: HTTPRequestHandling {</font><font size=3> </font><font size=2 face="Courier New"><br>
 &nbsp; &nbsp;func handle(request: HTTPRequest, response: HTTPResponseWriter
) -&gt; HTTPBodyProcessing {</font><font size=3> </font><font size=2 face="Courier New"><br>
 &nbsp; &nbsp; &nbsp; &nbsp;response.writeHeader(status: .ok)</font><font size=3>
</font><font size=2 face="Courier New"><br>
 &nbsp; &nbsp; &nbsp; &nbsp;response.writeBody(&quot;Hello, World!&quot;)</font><font size=3>
</font><font size=2 face="Courier New"><br>
 &nbsp; &nbsp; &nbsp; &nbsp;response.done()</font><font size=3> </font><font size=2 face="Courier New"><br>
 &nbsp; &nbsp; &nbsp; &nbsp;return .discardBody</font><font size=3> </font><font size=2 face="Courier New"><br>
 &nbsp; &nbsp;}</font><font size=3> </font><font size=2 face="Courier New"><br>
}</font><font size=3> <br>
</font><font size=2 face="Courier New"><br>
let server = HTTPServer()</font><font size=3> <br>
</font><font size=2 face="Courier New"><br>
try! server.start(port: 8080, handler: MyServer().handle)</font><font size=3>
<br>
<br>
</font><font size=2 face="sans-serif"><br>
Chris</font><font size=3> <br>
<br>
<br>
</font><font size=1 color=#5f5f5f face="sans-serif"><br>
From: &nbsp; &nbsp; &nbsp; &nbsp;</font><font size=1 face="sans-serif">Georgios
Moschovitis &lt;</font><a href=mailto:george.moschovitis@icloud.com><font size=1 color=blue face="sans-serif"><u>george.moschovitis@icloud.com</u></font></a><font size=1 face="sans-serif">&gt;</font><font size=3>
</font><font size=1 color=#5f5f5f face="sans-serif"><br>
To: &nbsp; &nbsp; &nbsp; &nbsp;</font><font size=1 face="sans-serif">Chris
Bailey &lt;</font><a href=mailto:BAILEYC@uk.ibm.com><font size=1 color=blue face="sans-serif"><u>BAILEYC@uk.ibm.com</u></font></a><font size=1 face="sans-serif">&gt;</font><font size=3>
</font><font size=1 color=#5f5f5f face="sans-serif"><br>
Cc: &nbsp; &nbsp; &nbsp; &nbsp;</font><a href="mailto:swift-server-dev@swift.org"><font size=1 color=blue face="sans-serif"><u>swift-server-dev@swift.org</u></font></a><font size=3>
</font><font size=1 color=#5f5f5f face="sans-serif"><br>
Date: &nbsp; &nbsp; &nbsp; &nbsp;</font><font size=1 face="sans-serif">03/09/2017
07:44</font><font size=3> </font><font size=1 color=#5f5f5f face="sans-serif"><br>
Subject: &nbsp; &nbsp; &nbsp; &nbsp;</font><font size=1 face="sans-serif">Re:
[swift-server-dev] HTTP API Review</font><font size=3> <br>
</font>
<hr noshade><font size=3><br>
<br>
<br>
Had a (very) quick look, and in general it looks OK. <br>
One thing that bothers me in the example is this ***Handler &lt;-&gt; ***Handling
inconsistency.. <br>
</font><font size=2 face="Courier New"><br>
class SimpleHandler: HTTPRequestHandling</font><font size=3> <br>
<br>
maybe something like <br>
<br>
class WebApp: HTTPRequestHandling { <br>
 &nbsp;... <br>
} <br>
<br>
would make it less confusing? <br>
<br>
-g. <br>
<br>
</font><font size=2 face="sans-serif"><br>
<br>
Unless stated otherwise above:<br>
IBM United Kingdom Limited - Registered in England and Wales with number
741598. <br>
Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6
3AU</font>
<br>
<br>
<br><font size=2 face="sans-serif"><br>
Unless stated otherwise above:<br>
IBM United Kingdom Limited - Registered in England and Wales with number
741598. <br>
Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6
3AU<br>
</font>