添加protorpc url变量

时间:2014-08-10 00:43:14

标签: python google-app-engine protorpc

有没有办法在protorpc服务路径中添加变量?与webapp2 url templates类似。

1 个答案:

答案 0 :(得分:0)

我认为您正在寻找资源容器:

来自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)