Skip to content

Instantly share code, notes, and snippets.

@phillip-haydon
Created September 25, 2013 02:11
Show Gist options
  • Save phillip-haydon/6694321 to your computer and use it in GitHub Desktop.
Save phillip-haydon/6694321 to your computer and use it in GitHub Desktop.
When given two routes:
Get["/{name}"] _ => "Hello, " + _.name;
Get["/phillip"] _ => "Phillip is awesome!";
Both these routes are identical, but we need to parse the url against both every time.
http://mysite.com/phillip
^ This route is matched twice.
Literal Segments are scored at 10k, while a Captured Segments are scored at 1k
The route that will be chosen will be `Get["/phillip"]`
http://mysite.com/bob
^ This route is matched only once.
These checks are nothing more than `if (segment == value)` so they are quick even if you have 100s of routes defined.
The only factor that can slow routes down is Regular Expressions, unless you define lots of regular expressions this will be quick.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment