What are ResourceContainers and how to use them for Cloud Endpoints?

故事扮演 提交于 2019-11-30 05:46:09

问题


Since Google AppEngine 1.8.5 there is a new warning in the development environment:

WARNING  2013-09-27 10:10:53,035 api_config.py:1768] Method specifies path
parameters but you are not using a ResourceContainer. This will fail in future
releases; please switch to using ResourceContainer as soon as possible.

What are ResourceContainers and how to use them?


回答1:


They recently updated the docs to explain this change here: Google App Engine Docs

Basically what you want to do is to separate the request body and the query/path parameters.

The request body will be a normal messages.Message class and you define any additional parameters in the ResourceContainer.

YOUR_RESOURCE_CONTAINER = endpoints.ResourceContainer(
        MyRequestBodyMessagesClass,
        parameter1=messages.IntegerField(2, required=True)
        parameter2=messages.StringField(3))

This change should help to minimize the amount of necessary Message classes because you can mostly reuse the RequestBody-Message for Response-Messages as well.

Note: if you are using the endpoints-proto-datastore there's an open issue about this.



来源:https://stackoverflow.com/questions/19048440/what-are-resourcecontainers-and-how-to-use-them-for-cloud-endpoints

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!