如果我有端点方法:
@endpoints.method(ProfileMiniForm, ProfileForm,
path='profile', http_method='POST', name='saveProfile')
def saveProfile(self, request):
"""Update & return user profile."""
return self._doProfile(request)
在saveProfile函数中,当它接收请求时,它是否接受了ProfileMiniform的实例?
答案 0 :(得分:1)
是的,我假设它基于您编写的protorpc
消息类。
让我们试试这里的例子:
class ProfileMiniForm(messages.Message):
message = messages.StringField(1)
class ProfileForm(messages.Message):
response = messages.StringField(1)
如果这些是您的输入和输出消息类,您将访问来自此类请求的message
数据成员:
@endpoints.method(ProfileMiniForm, ProfileForm,
path='profile', http_method='POST', name='saveProfile')
def saveProfile(self, request):
"""Update & return user profile."""
# get the ProfileMiniForm instance data in the request object
message = request.message
# return message object here, in this case a ProfileForm instance
return ProfileForm(response = message)