<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Also, <div class=""><br class=""></div><div class="">- `HTTPBodyProcessing` is a very long word with no obvious meaning.</div><div class="">- I would use `HTTPResponse` instead of `HTTPResponseWriter` </div><div class="">- I would rename `writeBody` to `write` (and, maybe, `writeHeader` to `addHeader`, `setHeader`, `appendHeader` or something similar)</div><div class=""><br class=""></div><div class="">-g.</div><div class=""><br class=""></div><div class=""><div><blockquote type="cite" class=""><div class="">On 3 Sep 2017, at 8:51 PM, Chris Bailey <<a href="mailto:BAILEYC@uk.ibm.com" class="">BAILEYC@uk.ibm.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><font size="2" face="sans-serif" class="">Hi Georgios:</font>
<br class="">
<br class=""><font size="2" face="sans-serif" class="">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>
<br class="">
<br class=""><font size="2" face="Courier New" class="">import HTTP</font>
<br class="">
<br class=""><font size="2" face="Courier New" class="">class MyServer: HTTPRequestHandling
{</font>
<br class=""><font size="2" face="Courier New" class=""> func handle(request:
HTTPRequest, response: HTTPResponseWriter ) -> HTTPBodyProcessing {</font>
<br class=""><font size="2" face="Courier New" class=""> response.writeHeader(status:
.ok)</font>
<br class=""><font size="2" face="Courier New" class=""> response.writeBody("Hello,
World!")</font>
<br class=""><font size="2" face="Courier New" class=""> response.done()</font>
<br class=""><font size="2" face="Courier New" class=""> return
.discardBody</font>
<br class=""><font size="2" face="Courier New" class=""> }</font>
<br class=""><font size="2" face="Courier New" class="">}</font>
<br class="">
<br class=""><font size="2" face="Courier New" class="">let server = HTTPServer()</font>
<br class="">
<br class=""><font size="2" face="Courier New" class="">try! server.start(port: 8080, handler:
MyServer().handle)</font>
<br class="">
<br class="">
<br class=""><font size="2" face="sans-serif" class="">Chris</font>
<br class="">
<br class="">
<br class="">
<br class=""><font size="1" color="#5f5f5f" face="sans-serif" class="">From:
</font><font size="1" face="sans-serif" class="">Georgios Moschovitis
<<a href="mailto:george.moschovitis@icloud.com" class="">george.moschovitis@icloud.com</a>></font>
<br class=""><font size="1" color="#5f5f5f" face="sans-serif" class="">To:
</font><font size="1" face="sans-serif" class="">Chris Bailey <<a href="mailto:BAILEYC@uk.ibm.com" class="">BAILEYC@uk.ibm.com</a>></font>
<br class=""><font size="1" color="#5f5f5f" face="sans-serif" class="">Cc:
</font><font size="1" face="sans-serif" class=""><a href="mailto:swift-server-dev@swift.org" class="">swift-server-dev@swift.org</a></font>
<br class=""><font size="1" color="#5f5f5f" face="sans-serif" class="">Date:
</font><font size="1" face="sans-serif" class="">03/09/2017 07:44</font>
<br class=""><font size="1" color="#5f5f5f" face="sans-serif" class="">Subject:
</font><font size="1" face="sans-serif" class="">Re: [swift-server-dev]
HTTP API Review</font>
<br class="">
<hr noshade="" class="">
<br class="">
<br class="">
<br class=""><font size="3" class="">Had a (very) quick look, and in general it looks OK.</font>
<br class=""><font size="3" class="">One thing that bothers me in the example is this ***Handler
<-> ***Handling inconsistency..</font>
<br class="">
<br class=""><font size="2" face="Courier New" class="">class SimpleHandler: HTTPRequestHandling</font>
<br class="">
<br class=""><font size="3" class="">maybe something like</font>
<br class="">
<br class=""><font size="3" class="">class WebApp: HTTPRequestHandling {</font>
<br class=""><font size="3" class=""> ...</font>
<br class=""><font size="3" class="">}</font>
<br class="">
<br class=""><font size="3" class="">would make it less confusing?</font>
<br class="">
<br class=""><font size="3" class="">-g.</font>
<br class="">
<br class="">
<br class=""><font size="2" face="sans-serif" class=""><br class="">
Unless stated otherwise above:<br class="">
IBM United Kingdom Limited - Registered in England and Wales with number
741598. <br class="">
Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6
3AU<br class="">
</font></div></blockquote></div><br class=""></div></body></html>