create route

pull/1/head
Matt Huntington 5 years ago
parent e0c010df76
commit 3e7ab0b772

@ -5,7 +5,9 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
@SpringBootApplication
@RestController
@ -21,4 +23,10 @@ public class DemoApplication {
public Iterable<Person> index() {
return personRepository.findAll();
}
@PostMapping(path="/people")
public Iterable<Person> create (@RequestBody Person personData) {
personRepository.save(personData);
return personRepository.findAll();
}
}

Loading…
Cancel
Save