// Path: src/main/java/com/mpalourdio/springboottemplate/mediatype/MediaType.java
// public final class MediaType extends org.springframework.http.MediaType {
// 
//     public static final org.springframework.http.MediaType APPLICATION_VND_API_V1;
//     public static final String APPLICATION_VND_API_V1_VALUE = "application/vnd.api.v1+json;charset=UTF-8";
// 
//     public static final org.springframework.http.MediaType APPLICATION_VND_API_V2;
//     public static final String APPLICATION_VND_API_V2_VALUE = "application/vnd.api.v2+json;charset=UTF-8";
// 
//     private MediaType(String type) {
//         super(type);
//     }
// 
//     static {
//         var applicationType = "application";
//         APPLICATION_VND_API_V1 = new org.springframework.http.MediaType(applicationType, "vnd.api.v1+json", StandardCharsets.UTF_8);
//         APPLICATION_VND_API_V2 = new org.springframework.http.MediaType(applicationType, "vnd.api.v2+json", StandardCharsets.UTF_8);
//     }
// }


import com.mpalourdio.springboottemplate.mediatype.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Collections;
import java.util.List;
/*
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */

package com.mpalourdio.springboottemplate.controllers;



/**
 * Running a GET request here with ACCEPT header = application/vnd.api.v1+json;q=0.9, application/json
 * will receive response from processV2.
 *
 * The same thing will happen if no ACCEPT header is specified
 *
 * @link https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html
 * @link http://allegro.tech/2015/01/Content-headers-or-how-to-version-api.html
 */


@RestController
@RequestMapping("/http")
public class HttpVersionedApiController {


    @GetMapping(value = "/test", produces = MediaType.APPLICATION_VND_API_V1_VALUE)
    public List<String> processV1() {
        return Collections.singletonList("v1");
    }

    @GetMapping(value = "/test", produces = {MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_VND_API_V2_VALUE})
    public List<String> processV2() {
        return Collections.singletonList("v2");
    }

    @PostMapping(
            value = "/test",
            consumes = MediaType.APPLICATION_VND_API_V1_VALUE,
            produces = MediaType.APPLICATION_VND_API_V1_VALUE
    )
    public List<String> processV1Post() {
// Path: src/main/java/com/mpalourdio/springboottemplate/mediatype/MediaType.java
// public final class MediaType extends org.springframework.http.MediaType {
// 
//     public static final org.springframework.http.MediaType APPLICATION_VND_API_V1;
//     public static final String APPLICATION_VND_API_V1_VALUE = "application/vnd.api.v1+json;charset=UTF-8";
// 
//     public static final org.springframework.http.MediaType APPLICATION_VND_API_V2;
//     public static final String APPLICATION_VND_API_V2_VALUE = "application/vnd.api.v2+json;charset=UTF-8";
// 
//     private MediaType(String type) {
//         super(type);
//     }
// 
//     static {
//         var applicationType = "application";
//         APPLICATION_VND_API_V1 = new org.springframework.http.MediaType(applicationType, "vnd.api.v1+json", StandardCharsets.UTF_8);
//         APPLICATION_VND_API_V2 = new org.springframework.http.MediaType(applicationType, "vnd.api.v2+json", StandardCharsets.UTF_8);
//     }
// }


// Path: src/main/java/com/mpalourdio/springboottemplate/controllers/HttpVersionedApiController.java
import com.mpalourdio.springboottemplate.mediatype.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Collections;
import java.util.List;

/*
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */

package com.mpalourdio.springboottemplate.controllers;



/**
 * Running a GET request here with ACCEPT header = application/vnd.api.v1+json;q=0.9, application/json
 * will receive response from processV2.
 *
 * The same thing will happen if no ACCEPT header is specified
 *
 * @link https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html
 * @link http://allegro.tech/2015/01/Content-headers-or-how-to-version-api.html
 */


@RestController
@RequestMapping("/http")
public class HttpVersionedApiController {


    @GetMapping(value = "/test", produces = MediaType.APPLICATION_VND_API_V1_VALUE)
    public List<String> processV1() {
        return Collections.singletonList("v1");
    }

    @GetMapping(value = "/test", produces = {MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_VND_API_V2_VALUE})
    public List<String> processV2() {
        return Collections.singletonList("v2");
    }

    @PostMapping(
            value = "/test",
            consumes = MediaType.APPLICATION_VND_API_V1_VALUE,
            produces = MediaType.APPLICATION_VND_API_V1_VALUE
    )
    public List<String> processV1Post() {
        return Collections.singletonList("v1-post");