<font size=2 face="sans-serif">That does of course work as well - and
may we'll be the preferred coding style. We should definitely document
both approaches.</font>
<br>
<br><font size=2 face="sans-serif">Chris</font>
<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:17</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>
<br><font size=2 face="sans-serif">How does the following look as a sample
"Hello World" app?</font><font size=3> </font>
<br>
<br><font size=3>Looks much better to me. I would prefer the following
though:</font>
<br>
<br>
<br><font size=3>import HTTP</font>
<br>
<br><font size=3>func handler(request: HTTPRequest, response: HTTPResponseWriter
) -> HTTPBodyProcessing { <br>
response.writeHeader(status: .ok) <br>
response.writeBody("Hello, World!") <br>
response.done() <br>
return .discardBody <br>
} </font>
<br>
<br><font size=3>try! HTTPServer().start(port: 8080, handler: handler)</font>
<br>
<br>
<br>
<br><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>