我正在使用Google Cloud Endpoints构建小型服务
class MyMsg(messages.Message):
f1 = messages.StringField(1, required=True)
@endpoints.api(...)
class MyService(remote.Service):
@endpoints.Method(MyMsg, MyMsg):
def test(self, request):
return request
当我在没有发送必要参数的情况下对此休息服务进行HTTP调用时,收到以下错误消息:
{
"error": {
"code": 400,
"errors": [
{
"domain": "global",
"message": "Error parsing ProtoRPC request (Unable to parse request content: Message MyMsg is missing required field f1)",
"reason": "badRequest"
}
],
"message": "Error parsing ProtoRPC request (Unable to parse request content: Message MyMsg is missing required field f1)"
}
}
有没有办法自定义此错误消息? 我想知道在错误响应中是否可以有类似下面的内容。
[
{
"field_name": "<>",
"error": "<>"
},
]