什么是ResourceContainers以及如何将它们用于云端点? [英] What are ResourceContainers and how to use them for Cloud Endpoints?

查看:200
本文介绍了什么是ResourceContainers以及如何将它们用于云端点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于Google AppEngine 1.8.5在开发环境中有一个新的警告:

 警告2013-09-27 10 :10:53,035 api_config.py:1768]方法指定路径
参数,但不使用ResourceContainer。这将在未来的
版本中失败;请尽快切换到使用ResourceContainer。

什么是ResourceContainers以及如何使用它们?

解决方案

他们最近更新的文档来解释这种变化在这里:的 Google App Engine Docs



基本上你想要做的是分开请求主体和查询/路径参数。 / p>

请求主体将是一个普通的 messages.Message 类,并且您可以在<$ c $中定义任何附加参数C> ResourceContainer

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

这个改变应该有助于减少必要的Message cla的数量因为你主要可以重用RequestBody-Message for Response-Messages。



注意:如果你使用端点-原数据存储有一个 open issue about this。


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?

解决方案

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.

这篇关于什么是ResourceContainers以及如何将它们用于云端点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆