<html><head><meta http-equiv="Content-Type" content="text/html; charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">I'm not convinced that using HTTPRequestHandling is a good protocol name. Why not use HTTPRequestHandler instead?<div class=""><br class=""></div><div class="">Alex<br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On 3 Sep 2017, at 18:51, Chris Bailey via swift-server-dev <<a href="mailto:swift-server-dev@swift.org" class="">swift-server-dev@swift.org</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>_______________________________________________<br class="">swift-server-dev mailing list<br class=""><a href="mailto:swift-server-dev@swift.org" class="">swift-server-dev@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-server-dev<br class=""></div></blockquote></div><br class=""></div></body></html>