I'm playing around with Jersey. I'm finding that PUT doesn't seem to
delegate to a sub-resource, while POST does...
Note how it simply outputs the class name...
@PUT
@Path("{keyId}")
public Class<? extends PostApiKeys> putApiKey(
@PathParam("keyId") final String keyId, @Valid ApiKey apiKey)
{
return PostApiKeys.class;
}
$ curl -X PUT -H 'Accept: application/json' -H "Content-Type:
application/json" -d '{"keyId": "2123", "verificationCode":
"cjklsdjlkjsdf"}' '
http://localhost:8080/eve-manufacturing-manager/api-keys/2123'
"com.github.trentonadams.eve.features.apikeys.services.PostApiKeys"
But with a POST, it works just fine...
/**
* Stores api keys using a service which simple returns 200, with a JSON
* response.
*
* @return the service for posting api keys.
*/
@Path("post")
public Class<? extends PostApiKeys> postService()
{
return PostApiKeys.class;
}
[03:12:12 trenta_at_developer-VirtualBox
~/LocalDocuments/development/java/eve-manufacturing-manager]
$ curl -X POST -H 'Accept: application/json' -H "Content-Type:
application/json" -d '{"keyId": "2123", "verificationCode":
"cjklsdjlkjsdf"}' '
http://localhost:8080/eve-manufacturing-manager/api-keys/post'
{"keyId":"2123","verificationCode":"cjklsdjlkjsdf"}
public interface IPostApiKeys
{
@POST
@Consumes({
MediaType.APPLICATION_JSON, MediaType.MULTIPART_FORM_DATA,
MediaType.APPLICATION_XML})
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
Response postForm(@Valid ApiKey apiKey) throws URISyntaxException;
@PUT
@Consumes({
MediaType.APPLICATION_JSON,
MediaType.APPLICATION_XML})
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
@Path("{keyId}")
Response putForm(@PathParam("keyId") String keyId, @Valid ApiKey apiKey)
throws URISyntaxException;
}