Giter Club home page Giter Club logo

Comments (6)

gwynne avatar gwynne commented on May 21, 2024 1

@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.

vzsg avatar vzsg commented on May 21, 2024

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.

keniwhat avatar keniwhat commented on May 21, 2024

This returns a list of 0 values. At least for a GET request with ':'-prefixed parameters in the url.

from routing-kit.

vzsg avatar vzsg commented on May 21, 2024

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.

keniwhat avatar keniwhat commented on May 21, 2024

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.

gwynne avatar gwynne commented on May 21, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.