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

ditch the route() argument #29

Closed
yoshuawuyts opened this issue Jul 20, 2016 · 6 comments
Closed

ditch the route() argument #29

yoshuawuyts opened this issue Jul 20, 2016 · 6 comments

Comments

@yoshuawuyts
Copy link
Owner

As @ahdinosaur pointed out to me today, the API could be a lil bit cleaner if we ditch the route() argument:

app.router('/404', [
  ['/', myView],
  ['/404', defaultView],
  ['/foo', myFooView, [
    ['/bar', myOtherView],
    ['/baz', yetAnotherView]
  ]]
])

What do people think?

@yoshuawuyts
Copy link
Owner Author

I think a tiny hello world router could then become:

app.router(['/', myView])

@ahdinosaur
Copy link

@yoshuawuyts what would happen when you don't specify a default, as in your hello world example? in my setup i used the last route as the default.

@timwis
Copy link
Contributor

timwis commented Jul 20, 2016

👍 to both ideas

@yoshuawuyts
Copy link
Owner Author

yoshuawuyts commented Jul 20, 2016

@ahdinosaur we could just detect if an arg was passed in - right now we throw if an incorrect path is called and we don't have a default path. I kinda like having it as the first arg; not too fond of magic tailing arguments haha - much rather detect arg count haha (':

@ahdinosaur
Copy link

@yoshuawuyts yeah that makes sense. my question is that if you call sheetRouter with a single routes argument, what is the default? i see you set dft to '', does that mean the root path (/) is the default? or does it throw if no other path matches like you say? happy with whatever, just want to make sure i understand what the behavior is.

@yoshuawuyts
Copy link
Owner Author

aye, so not setting a route; ('' or w/e) should make paths throw. Not sure if you can set / to be the default path (oops), but at least yeah that's the idea

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

3 participants