Comments (6)
@vzsg I don't think it's too unreasonable to make the list of matched parameter names available. I would suggest adding a property of this sort to Parameters
:
#if swift(>=5.7) // SE-0346
public var allNames: some Collection<String> { self.values.keys }
#else
public var allNames: some Collection { self.values.keys }
#endif
from routing-kit.
Have you seen catchAll? The documentation sure is lacking, but if you use that, you can access all parameters as a String array using req.parameters.getCatchall()
.
from routing-kit.
This returns a list of 0 values. At least for a GET request with ':'-prefixed parameters in the url.
from routing-kit.
Well yes, as written on the tin, this collects parameters that were matched by **
, not by named parameters. Since you apparently don't want to assign names to the parameters, this could be the way out: a route that ends with a catchall.
But could you provide an example scenario where you have named parameters but don't want to have named parameters at the same time? That's getting harder to imagine the more I think about it.
from routing-kit.
Here is an URL: http://192.168.1.24/api/product/:type/mediatype/:mediatype
Typically I would expect to be able to get a list of all paramaters and then using the names, collect the values and return them in a map.
My framework abstracts away the Web Container implementation and is URL-agnostic. I see no point in preventing the parameters from being picked up without knowing their names. Of course, further downstream something must know their names, but at the lower level it should not be enforced. No other framework I ever used did this.
But anyway ... I have implemented a workaround. It's awkward now, not impossible.
from routing-kit.
@keniwhat For the record, Vapor is not "enforcing" a lack of access to this information. It just hadn't occurred to anyone to make it available, and basic design principles of encapsulation say only make public what needs to be (though certainly Vapor is rather spotty in that regard) - and apparently it hasn't been a sufficiently significant concern for anyone to bother asking after it until now. I've opened a PR to resolve the missing functionality.
from routing-kit.
Related Issues (20)
- Incorrect Documentation for PathCompents
- add iOS platform in Package.swift
- how to get Anything parameter HOT 2
- Avoid print in TrieRouter.swift HOT 3
- warn if mis-match dynamic node registered HOT 3
- Only first route registration works HOT 7
- elementsEqual HOT 3
- Repo needs a pull request template
- Repo needs an issue template
- Integrate SwiftLint HOT 1
- Parameters should be percent escaped HOT 3
- Generalize route grouping
- Move percent encoding mechanism to Vapor HOT 2
- PathComponent.catchall not working as expected HOT 1
- Not working with localhost HOT 5
- Have to name all params the same HOT 1
- anything and parameter should be the same node HOT 8
- Trie Tree matching problem HOT 12
- Extraneous slashes and empty path components HOT 2
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 routing-kit.