<font size=2 face="sans-serif">>></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">>></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">>></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
"write()" for writeBody(), then we'd have to move to:</font>
<br><font size=2 face="sans-serif"> func
write(headers: HTTPHeaders, status: HTTPResponseStatus, completion: @escaping
(Result) -> Void)</font>
<br><font size=2 face="sans-serif"> func
write(body: UnsafeHTTPResponseBody, completion: @escaping (Result) ->
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:
</font><font size=1 face="sans-serif">Georgios Moschovitis
<george.moschovitis@icloud.com></font>
<br><font size=1 color=#5f5f5f face="sans-serif">To:
</font><font size=1 face="sans-serif">Chris Bailey <BAILEYC@uk.ibm.com></font>
<br><font size=1 color=#5f5f5f face="sans-serif">Cc:
</font><font size=1 face="sans-serif">swift-server-dev@swift.org</font>
<br><font size=1 color=#5f5f5f face="sans-serif">Date:
</font><font size=1 face="sans-serif">04/09/2017 20:26</font>
<br><font size=1 color=#5f5f5f face="sans-serif">Subject:
</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 <</font><a href=mailto:BAILEYC@uk.ibm.com><font size=3 color=blue><u>BAILEYC@uk.ibm.com</u></font></a><font size=3>>
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 "Hello World"
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>
func handle(request: HTTPRequest, response: HTTPResponseWriter
) -> HTTPBodyProcessing {</font><font size=3> </font><font size=2 face="Courier New"><br>
response.writeHeader(status: .ok)</font><font size=3>
</font><font size=2 face="Courier New"><br>
response.writeBody("Hello, World!")</font><font size=3>
</font><font size=2 face="Courier New"><br>
response.done()</font><font size=3> </font><font size=2 face="Courier New"><br>
return .discardBody</font><font size=3> </font><font size=2 face="Courier New"><br>
}</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: </font><font size=1 face="sans-serif">Georgios
Moschovitis <</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">></font><font size=3>
</font><font size=1 color=#5f5f5f face="sans-serif"><br>
To: </font><font size=1 face="sans-serif">Chris
Bailey <</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">></font><font size=3>
</font><font size=1 color=#5f5f5f face="sans-serif"><br>
Cc: </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: </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: </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 <-> ***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>
... <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>