Python中@Named API参数的等效项
是否有任何方法可以在Python中使用命名方法参数-对应于此Java示例:Python中@Named API参数的等效项,python,google-app-engine,rest,google-cloud-endpoints,Python,Google App Engine,Rest,Google Cloud Endpoints,是否有任何方法可以在Python中使用命名方法参数-对应于此Java示例: @ApiMethod( name = "foos.remove", path = "foos/{id}", httpMethod = HttpMethod.DELETE, ) public void removeFoo(@Named("id") String id) { } 在我的Python版本中,如果我将@endpoints.method路径设置为foos/{id},URL将正确匹配,但是如
@ApiMethod(
name = "foos.remove",
path = "foos/{id}",
httpMethod = HttpMethod.DELETE,
)
public void removeFoo(@Named("id") String id) {
}
在我的Python版本中,如果我将
@endpoints.method
路径设置为foos/{id}
,URL将正确匹配,但是如何访问参数?没有严格的等价项,但是如果{id}
在您的路径中,然后在方法中用于请求类的protorpc
消息类中必须有一个名为id
的字段
例如:
from google.appengine.ext import endpoints
from protorpc import messages
from protorpc import remote
class MyMessageClass(messages.Message):
id = messages.StringField(1) # Or any other field type
@endpoints.api(...)
class MyApi(remote.Service):
@endpoints.method(MyMessageClass, SomeResponseClass,
..., path='foos/{id}')
def my_method(self, request):
...
它应该只是方法的第一个参数。@Linuxios不适用于Python实现。这很有效,谢谢!如果在文档中提到它就好了。