Skip to content
Browse files
Add a super simple controller for listing and storing new registrations
Be aware: This is a HTTP/JSON based API but not a REST api ;) Use Spring Data REST for easy creation of such apis.
  • Loading branch information
michael-simons committed Aug 24, 2016
1 parent d40a48a commit fa22a8726dac1ec1e4138826a83c3b44a9aaa6cc
Showing 1 changed file with 37 additions and 0 deletions.
@@ -0,0 +1,37 @@
package ac.simons.netbeansevening;

import javax.validation.Valid;

import org.springframework.web.bind.annotation.PathVariable;
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.web.bind.annotation.RequestMethod.GET;
import static org.springframework.web.bind.annotation.RequestMethod.POST;

public class RegistrationController {

private final RegistrationRepository registrationRepository;

public RegistrationController(RegistrationRepository registrationRepository) {
this.registrationRepository = registrationRepository;

@RequestMapping(method = GET)
public Iterable<RegistrationEntity> list() {
return this.registrationRepository.findAll();

@RequestMapping(value = "/{id}", method = GET)
public RegistrationEntity get(@PathVariable Integer id) {
return this.registrationRepository.findOne(id);

@RequestMapping(method = POST)
public RegistrationEntity create(@Valid @RequestBody RegistrationEntity newRegistration) {

0 comments on commit fa22a87

Please sign in to comment.