Custom media types rest (#939)

* Custom Media Types for REST

* add test, add DTO, remove example of API versioning to make example simpler

* client accept only that custom-media type

* remove not needed new_line

* leave custom media type on class level

* do not need content type header

* GET do not need content-Type

* add liveTest for custom Content type

* Merge branch 'master' of https://github.com/eugenp/tutorials into Custom_media_types_rest

# Conflicts:
#	spring-rest/src/main/java/org/baeldung/web/controller/mediatypes/CustomMediaTypeController.java
#	spring-rest/src/main/java/org/baeldung/web/dto/BaeldungItem.java
#	spring-rest/src/test/java/org/baeldung/web/controller/mediatypes/CustomMediaTypeControllerTest.java
This commit is contained in:
Tomasz Lelek
2016-12-29 23:44:21 +01:00
committed by Eugen
parent 373f336b81
commit 0e163811ac
4 changed files with 47 additions and 3 deletions

View File

@@ -8,10 +8,10 @@ import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping(value = "/", produces = "application/vnd.baeldung.api.v1+json", consumes = "application/vnd.baeldung.api.v1+json")
@RequestMapping(value = "/", produces = "application/vnd.baeldung.api.v1+json")
public class CustomMediaTypeController {
@RequestMapping(value = "/public/api/endpoint", produces = "application/vnd.baeldung.api.v1+json", consumes = "application/vnd.baeldung.api.v1+json")
@RequestMapping(value = "/public/api/endpoint", produces = "application/vnd.baeldung.api.v1+json")
public @ResponseBody ResponseEntity<BaeldungItem> getItem() {
return new ResponseEntity<>(new BaeldungItem("itemId1"), HttpStatus.OK);
}