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

Coercion on route path and query paramaters #210

Open
drewverlee opened this issue Sep 24, 2021 · 1 comment
Open

Coercion on route path and query paramaters #210

drewverlee opened this issue Sep 24, 2021 · 1 comment

Comments

@drewverlee
Copy link

Greetings,

It would seem ideal to have coercion and defaults for path parameters and query parameters be expressed at the routing level so that downstream logic could share. I don't any documentation around this option and was wondering what should be done. My current plan is to add data to my route tree leafs containing the coercion and defaults and then search that tree for that information before passing it to our app db. One challenge here is that the structure of the bidi routes is unclear to me. e.g

["/" {...}] vs [{...}]

So it's not clear how i could universal search the tree. Let me know if you have any advice on this or on the wider topic. Maybe i should be thinking in terms of middleware?

Thanks, Drew.

@drewverlee drewverlee changed the title Coercion on route or path paramaters Coercion on route path and query paramaters Sep 24, 2021
@SevereOverfl0w
Copy link
Contributor

Bidi doesn't deal with query parameters, so those are probably going to be a problem to solve in user space. For coercing path parameters you can implement the pattern segment protocol. This allows you to implement custom processing for patterns.

The function implementation is a little harder to follow than I'd like for an example, as it's using cond, but serves as a good example of handling a few common cases (longs, uuids, etc.). I know you're plenty skilled with Clojure to follow it though!

Thanks Drew, please follow up if you have any more questions.

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

2 participants