Adding protorpc url variables

83 Views Asked by At

Is there a way to add a variable in the protorpc service path? Similar to webapp2 url templates.

1

There are 1 best solutions below

0
On

I think you are looking for a resource container:

from https://developers.google.com/appengine/docs/python/endpoints/getstarted/backend/write_api_post

ID_RESOURCE = endpoints.ResourceContainer:

MULTIPLY_METHOD_RESOURCE = endpoints.ResourceContainer(
        Greeting,
        times=messages.IntegerField(2, variant=messages.Variant.INT32,
                                    required=True))

@endpoints.method(MULTIPLY_METHOD_RESOURCE, Greeting,
                  path='hellogreeting/{times}', http_method='POST',
                  name='greetings.multiply')
def greetings_multiply(self, request):
    return Greeting(message=request.message * request.times)