Reputation: 389
Is there any way to used named method parameter in Python - corresponding to this Java example:
@ApiMethod(
name = "foos.remove",
path = "foos/{id}",
httpMethod = HttpMethod.DELETE,
)
public void removeFoo(@Named("id") String id) {
}
In my Python version, if I set the @endpoints.method
path to foos/{id}
the URL gets matched correctly, but how do I access the parameter?
Upvotes: 2
Views: 252
Reputation: 10163
There is not strict equivalent, but if {id}
is in your path, then there must be a field called id
in the protorpc
message class you use for the request class in the method.
For example:
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):
...
Upvotes: 6