/** * Test if the route definition can consume a media type. * * @param types A media types to test. * @return True, if the route can produces the given media type. */ public boolean canProduce(final MediaType... types) { return canProduce(Arrays.asList(types)); }
private static Err handle406or415(final Set<Route.Definition> routeDefs, final String method, final String path, final MediaType contentType, final List<MediaType> accept) { for (Route.Definition routeDef : routeDefs) { Optional<Route> route = routeDef.matches(method, path, MediaType.all, MediaType.ALL); if (route.isPresent() && !route.get().pattern().contains("*")) { if (!routeDef.canProduce(accept)) { return new Err(Status.NOT_ACCEPTABLE, accept.stream() .map(MediaType::name) .collect(Collectors.joining(", "))); } if (!contentType.isAny()) { return new Err(Status.UNSUPPORTED_MEDIA_TYPE, contentType.name()); } } } return null; }
/** * Test if the route definition can consume a media type. * * @param types A media types to test. * @return True, if the route can produces the given media type. */ public boolean canProduce(final MediaType... types) { return canProduce(Arrays.asList(types)); }
private static Err handle406or415(final Set<Route.Definition> routeDefs, final String method, final String path, final MediaType contentType, final List<MediaType> accept) { for (Route.Definition routeDef : routeDefs) { Optional<Route> route = routeDef.matches(method, path, MediaType.all, MediaType.ALL); if (route.isPresent() && !route.get().pattern().contains("*")) { if (!routeDef.canProduce(accept)) { return new Err(Status.NOT_ACCEPTABLE, accept.stream() .map(MediaType::name) .collect(Collectors.joining(", "))); } if (!contentType.isAny()) { return new Err(Status.UNSUPPORTED_MEDIA_TYPE, contentType.name()); } } } return null; }
/** * Test if the route definition can consume a media type. * * @param types A media types to test. * @return True, if the route can produces the given media type. */ public boolean canProduce(final String... types) { return canProduce(MediaType.valueOf(types)); }
/** * Test if the route definition can consume a media type. * * @param types A media types to test. * @return True, if the route can produces the given media type. */ public boolean canProduce(final String... types) { return canProduce(MediaType.valueOf(types)); }