Example usage for org.springframework.web.server NotAcceptableStatusException NotAcceptableStatusException

List of usage examples for org.springframework.web.server NotAcceptableStatusException NotAcceptableStatusException

Introduction

In this page you can find the example usage for org.springframework.web.server NotAcceptableStatusException NotAcceptableStatusException.

Prototype

public NotAcceptableStatusException(List<MediaType> supportedMediaTypes) 

Source Link

Document

Constructor for when the requested Content-Type is not supported.

Usage

From source file:org.springframework.security.web.server.util.matcher.MediaTypeServerWebExchangeMatcher.java

private List<MediaType> resolveMediaTypes(ServerWebExchange exchange) throws NotAcceptableStatusException {
    try {//from   w w  w  .  java2 s .  co  m
        List<MediaType> mediaTypes = exchange.getRequest().getHeaders().getAccept();
        MediaType.sortBySpecificityAndQuality(mediaTypes);
        return mediaTypes;
    } catch (InvalidMediaTypeException ex) {
        String value = exchange.getRequest().getHeaders().getFirst("Accept");
        throw new NotAcceptableStatusException(
                "Could not parse 'Accept' header [" + value + "]: " + ex.getMessage());
    }
}

From source file:org.springframework.web.reactive.accept.ParameterContentTypeResolver.java

@Override
protected MediaType handleNoMatch(String key) throws NotAcceptableStatusException {
    throw new NotAcceptableStatusException(getAllMediaTypes());
}