Add request method constraints to some request mappings
Some request mappings that were only intended to handle GET requests were unconstrained. The commit adds a method = GET constraint to those mappings to prevent them from handling other HTTP request methods
This commit is contained in:
@@ -20,13 +20,14 @@ import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo;
|
||||
|
||||
import org.springframework.hateoas.ResourceSupport;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/")
|
||||
public class IndexController {
|
||||
|
||||
@RequestMapping
|
||||
@RequestMapping(method=RequestMethod.GET)
|
||||
public ResourceSupport index() {
|
||||
ResourceSupport index = new ResourceSupport();
|
||||
index.add(linkTo(NotesController.class).withRel("notes"));
|
||||
|
||||
@@ -55,7 +55,7 @@ public class NotesController {
|
||||
this.noteResourceAssembler = noteResourceAssembler;
|
||||
}
|
||||
|
||||
@RequestMapping
|
||||
@RequestMapping(method = RequestMethod.GET)
|
||||
Iterable<NoteResource> all() {
|
||||
return this.noteResourceAssembler.toResources(this.noteRepository.findAll());
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ public class TagsController {
|
||||
this.resourceAssembler = resourceAssembler;
|
||||
}
|
||||
|
||||
@RequestMapping
|
||||
@RequestMapping(method = RequestMethod.GET)
|
||||
Iterable<TagResource> all() {
|
||||
return this.resourceAssembler.toResources(this.repository.findAll());
|
||||
}
|
||||
@@ -65,7 +65,7 @@ public class TagsController {
|
||||
return httpHeaders;
|
||||
}
|
||||
|
||||
@RequestMapping("/{id}")
|
||||
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
|
||||
Resource<Tag> tag(@PathVariable("id") long id) {
|
||||
Tag tag = this.repository.findOne(id);
|
||||
return this.resourceAssembler.toResource(tag);
|
||||
|
||||
Reference in New Issue
Block a user