Comments (5)
Hi Ragnar - this is a great feature request.
I hadn't considered this use-case but it's clearly a good thing if bidi continues to find a handler which does match. Obviously there is a determinstic order here, so I think it makes sense that bidi returns the first route that matches, but if there's missing parameters, it shouldn't blow up like it does, but continue seeking a match. Let me think over this for a bit longer and see if a good design occurs to me. I'll leave the issue open.
And please accept my apologies for taking so long to respond.
Regards,
Malcolm
from bidi.
Hi,
I just got into the same situation, these are my routes in question:
(def routes ["/" {"" :index
"v/" {[:source-id] {"" :composition
["/" :track-id] :composition}}
"s/" {[:search] :search-results}}])
The track-id
is an optional parameter, Bidi is able to match-route fine for both cases, but leaving the code as is the path-for
only works without the :track-id
(it's always ignored). By inverting the order I can generate with :track-id
but trying otherwise will blow up (like discussed before).
Would be great to have this feature.
from bidi.
This code looks like it is intended to solve this problem:
https://github.com/juxt/bidi/blame/335cb3165f873e8590199fcc20acb288104fe7ce/src/bidi/bidi.cljc#L451-L453
451 ;; If you have multiple routes which match the same handler, but need to
452 ;; label them so that you can form the correct URI, wrap the handler in
453 ;; a TaggedMatch.
Just adding a wrapper, e.g., (tag :mytag 'handler) in both the routes and path-for just makes it return nil, however. Can you clarify @malcolmsparks ? Is that code related to this problem? If not, are you open for a pull request?
from bidi.
Actually is should be (tag handler :mytag)
- the argument order of the TaggedMatch record was confusing (the tag
function was switching the args around). I've cleaned that up in the last commit.
I think this issue, in general, is addressed by the use of tags. If you want the same handler at more than one route, you can use tags to distinguish between them. I'm concerned that an approach which involved path-for continuing it's journey until it had uncovered every possible match would impact performance for everyone.
from bidi.
Sounds good, thank you!
from bidi.
Related Issues (20)
- Bidi brings older version of `ring-core` into projects; should it be :scope "provided"? HOT 1
- `just-path` removes # HOT 9
- Ring async handler support HOT 1
- X-Forwarded-Host is used over Host, can lead to security issues HOT 4
- Coercion around a route causes custom match extension records to be lost (affects vhosts) HOT 1
- Add Ataraxy in the comparison chart in the README.md
- compilation warnings (from a shadow-cljs project depending on [bidi "2.1.4"]) HOT 3
- Document uri-info better
- bidi.ring - alternates don't work
- Example with alpeh
- CLJS implementation does not parse longs properly
- Feature Request: Adding headers in a 307 redirect.
- Implementation of protocols for MultiFn HOT 2
- How to route to a pdf file
- Non-ASCII characters as path parameters
- Reflection warning on java.net.URLDecoder/decode
- resourcesMaybe no caching HOT 1
- filesmaybe missing
- Coercion on route path and query paramaters HOT 1
- Don't remove :handler from match-context
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bidi.