Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typed parameters #1

Closed
joeldev opened this issue Feb 11, 2013 · 9 comments
Closed

Typed parameters #1

joeldev opened this issue Feb 11, 2013 · 9 comments
Milestone

Comments

@joeldev
Copy link
Owner

joeldev commented Feb 11, 2013

Currently all parsed params come in as strings. While that's useful a lot of the time, there are still probably some cases where the developer has to convert it to, for example, a number.

In the interest of helping people not have to write that extra bit of code, I'd like to find some nice way to encode types in the route pattern string.

Instead of:
/post/view/:postID

It could be (this format is by no means final and only meant to illustrate the concept):
/post/view/:[postID:number]

JLRoutes would see that postID is declared as a number and just give you an NSNumber for that key instead of an NSString.

There is probably some set list of types where this makes any sense at all whatsoever.

@notjosh
Copy link

notjosh commented Feb 11, 2013

Instead of:
/post/view/:postID

It could be (this is format is by no means final and only meant to illustrate the concept):
/post/view/:postID

These look eerily similar ;)

@joeldev
Copy link
Owner Author

joeldev commented Feb 11, 2013

Heh, oops. I guess it didn't like the format I proposed. :P updated it. Thanks for pointing that out!

@zholmquist
Copy link

Why not use "#" instead of ":"?

post/view/#postID

@notjosh
Copy link

notjosh commented Feb 12, 2013

post/view/#postID

Why use "#" instead of ":"? I'd prefer ":" unless there's a real reason. "#" has other semantic meaning on web URLs - is that an issue here?

/post/view/:[postID:number]

Since we're used to seeing (NSNumber *)postID, I'd prefer to see the type prefix the variable, such as /post/view/:[number:postID].

What types should be considered? Numbers, obviously, but what about BOOLs? Nulls? Arrays (via ?foo[]=bar&foo[]=baz)? I think I'm probably overthinking it 😄

@joeldev
Copy link
Owner Author

joeldev commented Feb 12, 2013

Yeah I'm still trying to figure out what types make sense. Numbers and BOOLs are the most obvious choices.

Arrays are good too but there seems to be no actual standard about how arrays are represented in URLs, so I'm a bit cautious of that. I've seen key=value1&key=value2&key=value3, I've seen the one you suggested, and I've even seen weird things like key=[value1,value2,value3]. I don't really like any of them so I'm not sure how to just 'pick' one to be a standard.

@joeldev
Copy link
Owner Author

joeldev commented Feb 12, 2013

The other issue that I see here is that there isn't really an elegant way to handle typed URL parameters (read: GET params). Maybe that's okay? I even use a "debug=true" GET param example in the readme, but there would be no way to actually just tell JLRoutes that that's a BOOL even though you could tell it that any other regular parameter is a BOOL.

@joeldev
Copy link
Owner Author

joeldev commented Feb 24, 2013

Moving to future

@zakdances
Copy link

Why not allow any object to be passed? I'd like to be able to pass NSDictionaries and my own NSObject subclasses.

@joeldev
Copy link
Owner Author

joeldev commented May 2, 2014

I don't think this is worth doing. Closing.

@joeldev joeldev closed this as completed May 2, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants