Last active
January 22, 2016 05:08
-
-
Save abhirockzz/4c68d9b306cfdfbf6d06 to your computer and use it in GitHub Desktop.
Bean Validation in action in JAX-RS
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
@Path("users") | |
public class UsersResource { | |
@HeaderParam("token") | |
@Valid | |
private Token token; | |
@POST | |
@Produces("application/json") | |
@Consumes("application/json") | |
public void save(@Valid User user){ | |
System.out.println("saved :: " + user); | |
} | |
@GET | |
@Path("{name}") | |
@Produces("application/json") | |
public @Valid User get(@PathParam("name") String name){ | |
return new User(name, name+"@test.com"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment