strongly typing parameters in the route string #28

olsonjeffery opened this Issue May 22, 2009 · 0 comments


None yet

1 participant


right now, all parameters declared in a route are new'd up as locals in the route body, but always of type string. This is desirable default behavior, but consider the following:

Get 'foo/bar/{baz}':
  baz as string = params.baz // baz is a string

how about:

Get 'foo/bar/{baz as int}':
  baz as int = Int32.Parse(params.baz) // cast baz to an int

should prolly provide default parsers for: int, decimal, float, long, double, DateTime, etc...


Get 'foo/bar/{baz as json:SomeType}':
  baz as SomeType = JavaScriptSerializer().Deserialize[of SomeType](params.baz)

make sense?

also, how about:

public class SomeType:
  public def constructor(json as string):
    pass // parsing the string into an instance of this type goes here

Get 'foo/baz/{baz as custom:SomeType}':
  baz as SomeType = SomeType(params.baz)

That just about covers all the bases, don't you think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment