Last active
May 20, 2016 23:31
-
-
Save willitscale/bc3852d24e14212870d946d145dc44ae to your computer and use it in GitHub Desktop.
Sample PATCH with Map
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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