@Override public Optional<MediaType> accepts(final MediaType... types) { return req.accepts(types); }
@Override public Optional<MediaType> accepts(final String... types) { return req.accepts(types); }
@Override public Optional<MediaType> accepts(final List<MediaType> types) { return req.accepts(types); }
/** * True, if request accept any of the given types. * * @param types Types to test * @return True if any of the given type is accepted. */ default boolean is(final List<MediaType> types) { return accepts(types).isPresent(); }
/** * True, if request accept any of the given types. * * @param types Types to test * @return True if any of the given type is accepted. */ default boolean is(final MediaType... types) { return accepts(types).isPresent(); }
/** * True, if request accept any of the given types. * * @param types Types to test * @return True if any of the given type is accepted. */ default boolean is(final String... types) { return accepts(types).isPresent(); }
return accepts(ImmutableList.copyOf(types));
return accepts(MediaType.valueOf(types));
if (req.accepts(MediaType.html).isPresent()) {
static void install(final Env env, final Config conf) { String path = conf.getString("crash.httpshell.path"); Router router = env.router(); router.get(path + "/{cmd:.*}", router.promise("direct", (req, deferred) -> { MediaType type = req.accepts(MediaType.json) .map(it -> MediaType.json) .orElse(MediaType.html); PluginContext ctx = req.require(PluginContext.class); ShellFactory shellFactory = ctx.getPlugin(ShellFactory.class); Shell shell = shellFactory.create(null); String cmd = req.param("cmd").value().replaceAll("/", " "); ShellProcess process = shell.createProcess(cmd); ShellProcessContext spc = new SimpleProcessContext( result -> deferred.resolve(result.type(type))); process.execute(spc); })); }
@Override public Optional<MediaType> accepts(final MediaType... types) { return req.accepts(types); }
@Override public Optional<MediaType> accepts(final List<MediaType> types) { return req.accepts(types); }
@Override public Optional<MediaType> accepts(final String... types) { return req.accepts(types); }
/** * True, if request accept any of the given types. * * @param types Types to test * @return True if any of the given type is accepted. */ default boolean is(final MediaType... types) { return accepts(types).isPresent(); }
/** * True, if request accept any of the given types. * * @param types Types to test * @return True if any of the given type is accepted. */ default boolean is(final String... types) { return accepts(types).isPresent(); }
/** * True, if request accept any of the given types. * * @param types Types to test * @return True if any of the given type is accepted. */ default boolean is(final List<MediaType> types) { return accepts(types).isPresent(); }
return accepts(ImmutableList.copyOf(types));
return accepts(MediaType.valueOf(types));
if (req.accepts(MediaType.html).isPresent()) {