-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Path parameters can't have URL encoded values #566
Comments
We resolved our requirement via |
I am running into this issue but the suggested solution does not work for me. Is there a workaround? |
Ok after looking into this more I think it is WAI although I am not sure that I understand what its supposed to do. It seems that if a parameter has a ":" in it (in the escaped URL), then the parameter is not passed directly to the grpc call but there is some kind of processing to extract the verb. So I am trying to map something like: /v1/method/{param} and the URL is /v1/method/F%3A1234 which does not work. A suitable workaround seems to be to add an extra : to the end of the URL: /v1/method/F%3A1234%3A this seems like a hack to me though since the parameter is properly URL encoded. If the proxy can not handle proper URL path mappings (with the proper escaping) then am I just safer to pass parameters in query strings? |
I am also running into this issue and it's pretty troublesome. |
I'll reopen the issue since this seems to still be a problem. I don't know of any workarounds myself, and I'm not sure how this could possibly be solved without something like a wildcard in the router which isn't supported by the standard library router. Do you have any ideas? |
Hi, Basically : where
but if you do as said above :
I added some logs to start understanding how it works : // line 165
// ...
components := strings.Split(path[1:], "/")
l := len(components)
log.Printf("COMP 1: %+v", components) // HERE
var verb string
if idx := strings.LastIndex(components[l-1], ":"); idx == 0 {
if s.protoErrorHandler != nil {
_, outboundMarshaler := MarshalerForRequest(s, r)
sterr := status.Error(codes.Unimplemented, http.StatusText(http.StatusNotImplemented))
s.protoErrorHandler(ctx, s, outboundMarshaler, w, r, sterr)
} else {
OtherErrorHandler(w, r, http.StatusText(http.StatusNotFound), http.StatusNotFound)
}
return
} else if idx > 0 {
c := components[l-1]
components[l-1], verb = c[:idx], c[idx+1:]
log.Printf("COMP 2: %+v -- VERB: %s", components, verb) // HERE
} it prints 2018/08/20 14:49:36 COMP 1: [v1 test alias foo:bar:test]
2018/08/20 14:49:36 COMP 2: [v1 test alias foo:bar] -- VERB: test I don't know how it works, so i am posting what i've found so far, If it can helps |
Nice digging @Tommy-42, this will absolutely help others who may be wanting to test the same thing! If I find the time I might look at this but no promises I'm afraid. |
I found this issue, that is basically what we talked about |
Seems like that issue was closed with 7226a0d. Is this still a problem or did that fix this as well? |
I've done my test on the but the tricky part is I am using golang/protobuf which enforce the version of grpc-gateway which constrain me from setting up the master branch ( and may not be compatible too ). do you have a solution ? |
How do you mean using |
my bad, I did say something wrong. it is even more messed up ... :( I've # have to follow grpc-middleware
# see : https://github.com/grpc-ecosystem/go-grpc-middleware/blob/master/Gopkg.toml#L6
[[constraint]]
branch = "master"
name = "github.com/golang/protobuf" because but I am kinda stuck there. |
@Tommy-42 you can use an [[override]]
name = "github.com/golang/protobuf"
version = "1.1.0" https://golang.github.io/dep/docs/Gopkg.toml.html#dependency-rules-constraint-and-override |
Oh my ... huge thanks, it works great now ! |
Can you confirm this is fixed in master then so we can close this issue? |
yes, it is working with master branch, I am able to request thanks for the help ! |
Great, thanks for confirming! |
Helps fixing: - gogo#484 - grpc-ecosystem/grpc-gateway#566 via https://github.com/gogo/gateway Upstream issue: golang/protobuf#409 Original upstream patch by Paul Nichols (@pauln) here: golang/protobuf#409
I've added a test to
mux_test.go
to demonstrate:The text was updated successfully, but these errors were encountered: