I am working on a protoc plugin (3.2.0) and have one problem that I cannot 
figure out how to solve.

Given a proto like this:

import "google/api/annotations.proto";

service MyService {
    rpc MethodOne (model.MethodOneRequest) returns 
(model.MethodOneResponse) {
        option (google.api.http) = {
        post: "/v1/myservice/methodone"
        body: "*"
        };
    }
    rpc MethodTwo (model.MethodTwoRequest) returns 
(model.MethodTwoResponse) {}


In my plugin, I need to be able to get at the option values. I can see that 
they are in the corresponding MethodOption, when I 'toString()' the method 
option I see them:

Options: [72295728: "\"\030/v1/myservice/methodone:\001*"
]


What I cannot figure out is how to get that Option into an HttpRule so that 
I can process it in my plugin.

I have tried things like this, but the option-value is not marshaled from 
the original MethodOption ... 

final ExtensionRegistry registry = ExtensionRegistry.newInstance();
AnnotationsProto.registerAllExtensions(registry);
...
for (final ServiceDescriptorProto service : _services) {
final List<MethodDescriptorProto> methods = service.getMethodList();
for (final MethodDescriptorProto method : methods) {
// this all works fine, I can see the methods and request/response 
parameter types
///
final MethodOptions options = method.getOptions();
...
HttpRule rule = options.getExtension(AnnotationsProto.http);
... // the 'rule' is empty after this.

I have even tried this:

rule = HttpRule.parser().parseFrom(
CodedInputStream.newInstance(options.toByteArray()), registry);
// the 'rule' is still empty 


I know I'm missing something simple here, but cannot figure out what that 
might be ... anyone have any clues ?

Thanks
-JR







-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.

Reply via email to