<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Dec 10, 2015, at 1:01 PM, Matthew Davies via swift-users <<a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div style="font-family: Alegreya-Regular; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""> func get(url: String, ctrl: Controller.Type, method: String) {</div><div style="font-family: Alegreya-Regular; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""> let inst = ctrl.init()</div><div style="font-family: Alegreya-Regular; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><b class=""> // Run the method that is passed in here</b></div><div style="font-family: Alegreya-Regular; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""> }</div></div></blockquote></div><br class=""><div class="">Since HTTP only has a handful of standard methods/verbs, you can just define a Swift method for each one in your protocol (get, put, delete, etc.) and use a switch statement on the `method` parameter to dispatch to the right one.</div><div class=""><br class=""></div><div class="">This is a case where you wouldn’t want to use dynamic lookup anyway, since the method name you’d be looking up and calling would be chosen by the remote client. That’s the sort of thing that’s just begging to be exploited (I.e. someone opens a TCP socket and sends “getWithoutCheckingAuth /admin/secretdata.txt HTTP/1.1”…)</div><div class=""><br class=""></div><div class="">—Jens</div></body></html>