How are Google Endpoints Method Arguments Handled?

If I have the Endpoints method:

@endpoints.method(ProfileMiniForm, ProfileForm,
        path='profile', http_method='POST', name='saveProfile')
def saveProfile(self, request):
    """Update & return user profile."""
    return self._doProfile(request)

In the saveProfile function, when it takes in request, is it taking in an instance of ProfileMiniform?

Answers


Yeah, which I assume is based on a protorpc message class that you wrote.

So let's try for an example here:

class ProfileMiniForm(messages.Message):
    message = messages.StringField(1)

class ProfileForm(messages.Message):
    response = messages.StringField(1)

If these are your input and output message classes, you would access the message data member coming from a request like this:

@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) 

Need Your Help

Hide toolbar on scroll design support library

java android android-layout android-fragments

How to hide toolbar on scroll in recyclerview, which is located in fragment in viewpager, if using new design support library?

is there any options to display infoWindow automatically on page load

javascript jquery google-maps google-maps-api-3

I'm using GMaps to display a map on my website. It is pretty easy to create a map with an infoWindow. However, the infoWindow only appears when the marker is clicked.