<div dir="ltr"><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">Okay I'll have to dig more into using that sort of syntax.</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">And no problem ;)</div></div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div dir="ltr"><div><br></div><div><div style="color:rgb(136,136,136);font-size:12.8000001907349px;max-width:600px;direction:ltr"><div style="max-width:470px;margin:8px 8px 0px 0px"><table border="0" cellspacing="0" cellpadding="0" width="470" style="width:470px"><tbody><tr valign="top"><td style="font-family:Arial;font-stretch:normal;font-size:14px;color:rgb(100,100,100);padding-left:10px"><div><b>Matthew Davies</b><br>Junior Developer, <a href="http://geostrategies.com" target="_blank">GeoStrategies</a></div><div>Director of Photography, <a href="http://offblockfilms.com" target="_blank">OffBlock Films</a></div><div style="color:rgb(141,141,141);font-size:13px;padding:5px 0px"><a href="tel:209-225.3246" style="color:rgb(141,141,141);text-decoration:none" target="_blank">209-225-3246</a> <span style="color:rgb(102,102,102);display:inline-block">|</span> <span style="display:inline-block"><a href="tel:209-202-3284" style="color:rgb(141,141,141);text-decoration:none" target="_blank">209-202-3284</a></span> <span style="color:rgb(102,102,102);display:inline-block">|</span> <span style="display:inline-block"><a href="mailto:daviesgeek@gmail.com" style="color:rgb(141,141,141);text-decoration:none" target="_blank">daviesgeek@gmail.com</a></span> <span style="color:rgb(102,102,102);display:inline-block">|</span> <span style="white-space:nowrap;display:inline-block"><a href="https://daviesgeek.com/" style="color:rgb(141,141,141);text-decoration:none" target="_blank">daviesgeek.com</a></span></div><div style="margin-top:5px"><a href="http://facebook.com/daviesgeek" style="color:rgb(17,85,204)" target="_blank"><img src="https://s3.amazonaws.com/images.wisestamp.com/icons/facebook.png" width="16" height="16"></a> <a href="http://us.linkedin.com/in/daviesgeek" style="color:rgb(17,85,204)" target="_blank"><img src="https://s3.amazonaws.com/images.wisestamp.com/icons/linkedin.png" width="16" height="16"></a> <a href="http://twitter.com/daviesgeek" style="color:rgb(17,85,204)" target="_blank"><img src="https://s3.amazonaws.com/images.wisestamp.com/icons/twitter.png" width="16" height="16"></a> <a href="http://daviesgeek.com/feed.xml" style="color:rgb(17,85,204)" target="_blank"><img src="https://s3.amazonaws.com/images.wisestamp.com/icons/blogRSS.png" width="16" height="16"></a> <a href="http://github.com/daviesgeek" style="color:rgb(17,85,204)" target="_blank"><img src="https://s3.amazonaws.com/images.wisestamp.com/icons/github.png" width="16" height="16"></a></div></td></tr></tbody></table></div><br></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div>
<br><div class="gmail_quote">On Thu, Dec 10, 2015 at 4:12 PM, Brent Royal-Gordon <span dir="ltr"><<a href="mailto:brent@architechies.com" target="_blank">brent@architechies.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">(Sorry for the repeat, Matthew.)<br>
<span class="im HOEnZb"><br>
> Can you clarify a bit on that? So, what you're saying is to generate routing code based off the DSL router I've written?<br>
<br>
</span><div class="HOEnZb"><div class="h5">Yes, unless you can modify your DSL so you can directly provide your controller classes, you’ll probably need to generate code.<br>
<br>
By “provide your controller classes”, I mean that you could make a routes file which looked something like this (this routing syntax is loosely inspired by Rails):<br>
<br>
import MyFramework.Router<br>
<br>
// UsersController.self is an instance which represents the UsersController class.<br>
// It’s of type UsersController.Type, which might (for instance) be a subtype of WebController.Type, etc.<br>
Router.root.resources(UsersController.self, path: “users”) { users in<br>
users.resources(PostsController.self, path: “posts”) { posts in<br>
// PostsController.comments is a way to retrieve a closure which calls PostsController’s comments() instance method.<br>
// You use it by saying something like `myClosure(myControllerInstance)(arg1, arg2, etc)`.<br>
posts.get(PostsController.comments, path: “comments”)<br>
}<br>
users.resources(CommentsController.self, path: “comments”)<br>
}<br>
<br>
Note that in all cases you pass instances, not names, to your routing APIs. This allows you to write code that can work with any compatible class or method without any danger of trying to use a class or method that doesn’t exist.<br>
<br>
But using this approach limits the flexibility of your routing DSL’s design. For instance, you can’t just take the string “users” and infer that you should use UsersController. If you want that sort of more sophisticated behavior, you’re going to need to generate Swift code instead.<br>
<br>
--<br>
Brent Royal-Gordon<br>
Architechies<br>
<br>
</div></div></blockquote></div><br></div>