Skip to content

Instantly share code, notes, and snippets.

@willitscale
Last active May 20, 2016 23:31
Show Gist options
  • Save willitscale/bc3852d24e14212870d946d145dc44ae to your computer and use it in GitHub Desktop.
Save willitscale/bc3852d24e14212870d946d145dc44ae to your computer and use it in GitHub Desktop.
Sample PATCH with Map
curl -X PATCH -H "Content-Type: application/json" -H "Cache-Control: no-cache" -d '{"datas":[
{"firstName":"John", "lastName":"Doe"},
{"firstName":"Anna", "lastName":{"MAPS":"Smith"}},
{"firstName":"Peter", "beans":213}
]}' "https://localhost/rest/test-patch/1"
import javax.ws.rs.HttpMethod;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target({ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@HttpMethod("PATCH")
public @interface PATCH {
}
Status:200 OK
Time:15 ms
Connection →keep-alive
Content-Encoding →gzip
Content-Type →text/html
Date →Fri, 20 May 2016 23:24:04 GMT
Server →nginx/1.10.0 (Ubuntu)
Transfer-Encoding →chunked
Vary →Accept-Encoding
{datas=[{firstName=John, lastName=Doe}, {firstName=Anna, lastName={MAPS=Smith}}, {firstName=Peter, beans=213}]}
import javax.annotation.Resource;
import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import java.util.Map;
@Resource
@Path("/test-patch")
public class TestResource {
@PATCH
@Path("/{id}")
@Produces(MediaType.TEXT_HTML)
@Consumes(MediaType.APPLICATION_JSON)
public Response patch(@PathParam("id") Integer id, Map<String,Object> datas) {
return Response.ok(datas.toString()).build();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment