Comments (7)
Confirmed that it works. It's possible to achieve the above by doing:
get: "/v1/dirs/{dir_path=**}"
from grpc-gateway.
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.
@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.
@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.
@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.
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.
Thank you for resolving this!
from grpc-gateway.
Related Issues (20)
- genopenapi: Stable openapi names for nested types HOT 1
- snake_case response HOT 1
- api_visibility doesn't transitively apply to rpc request/response messages HOT 2
- protoc-gen-grpc-gateway and protoc-gen-openapiv2 return incorrect version HOT 1
- Dependency on google.golang.org/grpc/health/grpc_health_v1 conflicts with custom proto marshallers HOT 5
- JSONPb marshaler doesn't use indent on non proto fields
- WriteHeader is not called on 200s HOT 1
- How to set cookie to http response header? Why it doesn't work. HOT 2
- Adding custom mux endpoint to openapi output HOT 3
- The API Gateway Vision HOT 2
- Support disabling default response rendering in bazel rule HOT 1
- Example and pattern annotations are not respect for query and path parameters HOT 8
- FieldMask as query param is not converted to snake case HOT 1
- an google.protobuf.Any type how to get openapiv2 output? HOT 1
- omit-enum-default-value Generates Invalid Spec for Enums with a Single Value HOT 1
- Content-Length not set in ForwardResponseMessage HOT 5
- Log level for errors is "info" HOT 5
- On `context deadline exceeded`, response headers aren't set HOT 3
- Add support for Etag & If-None-Match headers HOT 6
- TestOutgoingTrailerMatcher is non-deterministic
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 grpc-gateway.