Created
January 1, 2018 17:19
-
-
Save chathurangat/c15528cc972a448a704dd03f78b9cbbc to your computer and use it in GitHub Desktop.
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 com.springbootdev.examples.domain.entity.User; | |
import com.springbootdev.examples.domain.repository.UserRepository; | |
import org.springframework.beans.factory.annotation.Autowired; | |
import org.springframework.web.bind.annotation.PostMapping; | |
import org.springframework.web.bind.annotation.RequestBody; | |
import org.springframework.web.bind.annotation.RequestMapping; | |
import org.springframework.web.bind.annotation.RestController; | |
import static org.springframework.http.MediaType.*; | |
@RestController | |
@RequestMapping("/api") | |
public class UserController | |
{ | |
@Autowired | |
private UserRepository userRepository; | |
@PostMapping( | |
value = "/users", | |
consumes = {APPLICATION_JSON_VALUE, APPLICATION_XML_VALUE}, | |
produces = {APPLICATION_JSON_VALUE, APPLICATION_XML_VALUE} | |
) | |
public User create(@RequestBody User user) | |
{ | |
return userRepository.save(user); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment