Skip to content
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

Not able to pass allow_delete_body to protoc-gen-grpc-gateway. #402

Closed
uynap opened this issue May 29, 2017 · 8 comments
Closed

Not able to pass allow_delete_body to protoc-gen-grpc-gateway. #402

uynap opened this issue May 29, 2017 · 8 comments

Comments

@uynap
Copy link

uynap commented May 29, 2017

I looked through the documents and searched the google. I tried to pass "allow_delete_body" to protoc-gen-grpc-gateway but failed.

It ends up with the question: how to pass the "allow_delete_body" to protoc-gen-grpc-gateway when issuing "protoc"?

Here's my currently protoc command:

protoc -I${GOPATH}/src/google.golang.org/genproto/googleapis \
      -I${GOPATH}/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis \
      -I${GOPATH}/src/github.com/golang/protobuf/ptypes \
      -I${GOPATH}/src \
      -I. \
      --plugin=protoc-gen-grpc-gateway=${GOPATH}/bin/protoc-gen-grpc-gateway --allow_delete_body=true \
      --go_out=plugins=grpc:. \
      --grpc-gateway_out=logtostderr=true:. \
      ${SOURCEDIR}/proto/route/*.proto

I got error message:
Unknown flag: --allow_delete_body

@tamalsaha
Copy link
Collaborator

I am guessing you are using old version of plugin. This flag was added recently. https://github.com/grpc-ecosystem/grpc-gateway/commits/master

@uynap
Copy link
Author

uynap commented May 29, 2017

@tamalsaha I think I'm using the latest one.

$ ~/go/bin/protoc-gen-grpc-gateway --help
Usage of /Users/py/go/bin/protoc-gen-grpc-gateway:
  -allow_delete_body
    	unless set, HTTP DELETE methods may not have a body

I saw it's a recently added feature.

@uynap
Copy link
Author

uynap commented May 29, 2017

I also tried to run

~/go/bin/protoc-gen-grpc-gateway --allow_delete_body

without any issue.

That's why I guess the problem is "the way" I passed it to "protoc" is wrong.

@achew22
Copy link
Collaborator

achew22 commented May 29, 2017

@uynap last time I played the protoc flag game was > 1 year ago so I'm working from foggy memories. I do think the problem is the way you're passing your flag into protoc. Could you try:

protoc -I${GOPATH}/src/google.golang.org/genproto/googleapis \
      -I${GOPATH}/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis \
      -I${GOPATH}/src/github.com/golang/protobuf/ptypes \
      -I${GOPATH}/src \
      -I. \
      --plugin=protoc-gen-grpc-gateway=${GOPATH}/bin/protoc-gen-grpc-gateway --allow_delete_body=true \
      --go_out=plugins=grpc:. \
      --grpc-gateway_out=logtostderr=true:allow_delete_body=true:. \
      ${SOURCEDIR}/proto/route/*.proto

Notice that I added it to the --grpc-gateway_out flag. I think the syntax, again this is an old memory, is argument1=value:argument2=value:path_to_generate_your_files_in.

@tamalsaha
Copy link
Collaborator

I believe the flags are comma separated. Here is a snippet from our build scripts:

  protoc -I /usr/local/include -I . \
         -I ${GOPATH}/src/github.com \
         -I ${GOPATH}/src/github.com/googleapis/googleapis/ \
         -I ${GOPATH}/src/github.com/grpc-ecosystem/grpc-gateway/third_party/appscodeapis \
         --grpc-js-client_out=logtostderr=true,remove_prefix=/_appscode/api,${ALIAS}:. *.proto

@achew22
Copy link
Collaborator

achew22 commented May 29, 2017

@tamalsaha, thanks for following up. Given that his sample came from a real makefile instead of the back of my head I would like to revise my question. Can you try this out:

protoc -I${GOPATH}/src/google.golang.org/genproto/googleapis \
      -I${GOPATH}/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis \
      -I${GOPATH}/src/github.com/golang/protobuf/ptypes \
      -I${GOPATH}/src \
      -I. \
      --plugin=protoc-gen-grpc-gateway=${GOPATH}/bin/protoc-gen-grpc-gateway --allow_delete_body=true \
      --go_out=plugins=grpc:. \
      --grpc-gateway_out=logtostderr=true,allow_delete_body=true:. \
      ${SOURCEDIR}/proto/route/*.proto

@uynap
Copy link
Author

uynap commented May 29, 2017

@tamalsaha Thanks a lot! It's exactly what I'm looking for. It is "comma separated".
Do you know where I can find documents on how to write "protoc" arguments? I read a lot of gRPC and related documents, but never seen it before.

@uynap uynap closed this as completed May 29, 2017
@tamalsaha
Copy link
Collaborator

@uynap , not sure where I found that. It has a been while. Usually bit of trial and error and head scratching gets the job done. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants