jacksonh.tumblr.com

3 notes &

Simple Route Patterns in Manos

After looking at some ugly regexs I decided to implement a simple pattern matching system for routes in Manos. You can now use strings like this for your routes:

[Get ("/articles/{slug}/{page}")]
public static void Articles (ManosApp app, IManosContext ctx, string slug, int page)
{
}

[Route ("/{foo}/{bar}")]
public void Foo (IManosContext ctx)
{
}

Everything inside of the { } block is matched as a string, but can be converted to any type by the action invoker.

If you really want a { in your url string (even though its an illegal url char) you can double them up for escaping {{ or }}. Note: I might just disable this feature since its kind of pointless.

  1. jacksonh posted this