Purpose of @Named in Google Cloud Endpoints
google-cloud-endpoints
Solution
EDIT: although my answer below is not really wrong, it's not complete at all. Basically when you add `@Named` annotation, the parameters will be included at the end of the request URL:
http://endpointurl?parameter1=xxx¶meter2=yyy
If you don't use `@Named`, the parameter will be included (injected) within the POST data. You can see it very clear by creating a test endpoint with some named parameters and some unnamed ones, and using some request explorer tool such as Firebug.
Obviously the parameter types that support `@Named` annotation are only a few (int, long, String, Boolean and their correspondent arrays, I think).
What I said in my original answer below isn't false, but is not a complete answer...
Original answer: As far as I understand, the purpose of @Named is to indicate the name of the parameter in the request URL. This way a parameter can have a name within your app and other name exposed in the endpoint.
It's pretty much the same that @SerializedName in GSON or @Column in JDO. All these annotations allow to have 2 different names for your parameters, one in your app, following Java naming conventions, and another name following other conventions such as URL or JSON ones...
In your example you can't note the difference, but you can have this method:
@ApiMethod(
name = "remove",
path = "remove",
httpMethod = HttpMethod.DELETE)
public void removeFoo(@Named("my_app_id") String myAppID){}
In this case the name of the parameter in the URL would be:
https://mygaeappid.appspot.com/_ah/api/yourapi/v1/remove?my_app_id=1234
And no, the @Named object doesn't always have to be part of the path defined in ApiMethod.
Problem
It's not clear to me what @Named is used for in Google Cloud Endpoints. The documentation says: This annotation indicates the name of the parameter in the request that gets injected here. A parameter that is not annotated with @Named is injected with the whole request object. ... This sample shows the use of @Named: ``` @ApiMethod( name = "foos.remove", path = "foos/{id}", httpMethod = HttpMethod.DELETE) public void removeFoo(@Named("id") String id){} ``` where @Named specifies that only the id parameter is injected in the request. If @Named was not used in this example, what instead is "injected"? with the "whole request"? For that matter, what exactly is "injected"? And what is the "whole request"? Does the @Named object always have to be part of the path defined in @Apimethod? Thanks.