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

Default segment specification in named routes #52

Closed
GetContented opened this issue Sep 21, 2014 · 8 comments
Closed

Default segment specification in named routes #52

GetContented opened this issue Sep 21, 2014 · 8 comments

Comments

@GetContented
Copy link

I'd like to be able to specify a route similar to this:

(defroute my-path "/design/:filter-name/:id" [filter-name id]
  ; do something
  )

(my-path {:id 5}) ; currently yields "/design/:filter-name/5", but I'd like to be able to specify a default for filter-name

And have the generated named path be able to specify default values to the parameters, rather than a keyword being used. I'm not really sure how this could be accomplished.

This is pretty closely related to having trailing slashes being elided, too... these two use-cases seem to be common enough that a solution would be really great to have in secretary itself, perhaps.

@GetContented
Copy link
Author

Nevermind. I worked out how to do this with standard defn calls and by using more defroute calls.

@gf3
Copy link
Collaborator

gf3 commented Sep 23, 2014

Yay!

@GetContented
Copy link
Author

Could probably deal with some tasty macros sometime tho to make this common stuff easier, IMHO... after I've used it for a bit longer if I have something extractible, I'll submit a PR :)

@gf3
Copy link
Collaborator

gf3 commented Sep 24, 2014

@JulianLeviston you might actually be able to accomplish what you suggested with "nested routes" which are upcoming in 2.0.0.

@GetContented
Copy link
Author

Yep, that sounds about right :). Hopefully they treat unspecified intervening route segments in a nice way (ie with supplied defaults).

@noprompt
Copy link
Collaborator

@JulianLeviston I would hold off until the 2.0.0 stuff is ironed out. IMHO I don't think adding more macros to the library will buy is anything a programmer couldn't do themselves. At the company I work at, we've been developing against using the 2.0.0 branch and have been able to do everything without macros - including context. Have a look at #50.

@GetContented
Copy link
Author

Cool. Still think it'd be nice and useful to have defaults for segments. All good tho :) 2 looks awesome!

@noprompt
Copy link
Collaborator

@JulianLeviston I misread your original request. I think defaults might be possible. Let me think about.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants