Skip to content

Instantly share code, notes, and snippets.

@iamvickyav
Last active July 28, 2020 08:13
Show Gist options
  • Save iamvickyav/08c1d6f9e5d9e611f3eed863d7be130f to your computer and use it in GitHub Desktop.
Save iamvickyav/08c1d6f9e5d9e611f3eed863d7be130f to your computer and use it in GitHub Desktop.
public class User {
private Integer id;
private String name;
private Date dob;
private String city;
// constructors, getters & setters are ignored
}
@RestController
public class UserController {
@Autowired
UserService userService;
@RequestMapping(value = "/user/{name}", method= RequestMethod.GET)
User getUserByName(@PathVariable("name") String name){
return userService.getUser(name);
}
@RequestMapping(value = "/users", method= RequestMethod.GET)
List<User> getAllUsers(){
return userService.getAllUsers();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment