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

Generate URL with query params? #28

Open
cjohansen opened this issue Feb 27, 2017 · 4 comments
Open

Generate URL with query params? #28

cjohansen opened this issue Feb 27, 2017 · 4 comments

Comments

@cjohansen
Copy link

Is there any way to generate a URL for a route with some additional query parameters? I would want to do something like (silk/depart routes :login {} {:query {"returnUrl" "/somewhere"}}), but AFAICT there's no way to feed query params into depart. Am I holding it wrong?

@domkm
Copy link
Owner

domkm commented Feb 28, 2017

There is not. Why would you want to do that instead of encoding them into the route itself?

@cjohansen
Copy link
Author

I could be convinced there's a better choice. I need to add an optional value to the generated URL - the login page takes a returlUrl query parameter, but it is not required. Also, I would prefer to encode this value as a query parameter, not part of the path, as it is optional and the page is the same.

If there's already a way to do this I'm eager to hear about it. If not, I'm hopeful you'll consider making it a feature.

@livtanong
Copy link

Generating a URL via query params does work, but not in the way @cjohansen wants.

(def routes
  (silk/routes [[:foo [["bar" :herp] {"baz" :burp}]]]))

(silk/depart routes :foo {:herp "derp" :burp "kangaroo"})
;; "/bar/derp?baz=kangaroo"

@domkm
Copy link
Owner

domkm commented Jul 26, 2017

@cjohansen My sincere apologies for letting this slip through. I don't recall receiving a notification of your response.

@levitanong Thanks for chiming in and drawing my attention.

Would using silk/? provide the optional param functionality that you're looking for?

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