Last active
March 10, 2016 14:12
-
-
Save brunokrebs/c02cd316196dfe6d1c8e to your computer and use it in GitHub Desktop.
This file contains hidden or 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
package br.com.brunokrebs.rest; | |
// ... previously added imports ... | |
import br.com.brunokrebs.repository.UserRepository; | |
import java.util.List; | |
@RestController | |
public class UserRest { | |
@Autowired | |
private UserRepository userRepository; // our nice repository implementation | |
@RequestMapping(path = "/users/", method = RequestMethod.POST) | |
public User saveUser(@RequestBody User user) { | |
userRepository.save(user); // using it to persist | |
return user; | |
} | |
@RequestMapping(path = "/users/", method = RequestMethod.GET) | |
public List<User> getUsers() { | |
return userRepository.findAll(); // returning all persisted users | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment