GithubHelp home page GithubHelp logo

Comments (7)

dmitshur avatar dmitshur commented on June 7, 2024 1

Confirmed that it works. It's possible to achieve the above by doing:

get: "/v1/dirs/{dir_path=**}"

from grpc-gateway.

dmitshur avatar dmitshur commented on June 7, 2024

I just realized (thanks @sqs) that I missed a very important bit:

* matches a single path component, ** zero or more path components.

So it is possible.

from grpc-gateway.

slimsag avatar slimsag commented on June 7, 2024

@shurcooL Do I understand your findings here correctly?

get: "/v1/dirs/{dir_path}"

Would match only a single path element (but it could be a URI encoded path). Whereas:

get: "/v1/dirs/{dir_path=**}"

Would match multiple path elements (that are not URI encoded)?

from grpc-gateway.

dmitshur avatar dmitshur commented on June 7, 2024

@slimsag Yes, the above is correct.

(but it could be a URI encoded path)

I don't think so. This is a url path element, not a query parameter. Edit: I could be mistaken, see e.g., golang/go#5777 (comment).


However, I'm reopening this because I find that it only works if such segment is at the end of the route. It doesn't seem to work when it's in the middle.

For example, this works:

get: "/v1/dirs/{dir_path=**}"

// They all work.
/v1/dirs/foo
/v1/dirs/foo/bar
/v1/dirs/foo/bar/baz

But this does not work:

get: "/v1/dirs/{dir_path=**}/.files"

// None of these get matched.
/v1/dirs/foo/.files
/v1/dirs/foo/bar/.files
/v1/dirs/foo/bar/baz/.files

Is that a bug?

from grpc-gateway.

yugui avatar yugui commented on June 7, 2024

@shurcooL Your question is whether the multi-segment wildcard ** is greedy or not.
I believe it is and I implemented the match mechanism as greedy by intention. But it is not clearly described in the spec.
We might need to ask the spec owner.

from grpc-gateway.

dmitshur avatar dmitshur commented on June 7, 2024

Your question is whether the multi-segment wildcard ** is greedy or not.

That is true. I agree that the spec doesn't seem to specify one way or the other. Thanks for looking into it.

from grpc-gateway.

dmitshur avatar dmitshur commented on June 7, 2024

Thank you for resolving this!

from grpc-gateway.

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.