@Override public String getRequestHeader(final String name) { return req.header(name).value(null); }
@Override public void handle(final Request req, final Response rsp) throws Throwable { String error = req.param("error").value(""); String username = req.param("username").value(""); req.set("username", username); req.set("error", error); // default login form rsp.type(MediaType.html).send(String.format(FORM, error, callback, username)); }
private String profileID(final boolean useSession, final Request req) { return req.<String>ifGet(Auth.ID) .orElseGet(() -> useSession ? req.session().get(Auth.ID).value(null) : null); }
@Override public Object getSessionAttribute(final String name) { Session session = req.session(); return AuthSerializer.strToObject(session.get(name).value(null)); }
@Override public String getRequestContent() { return Try.apply(() -> req.body().value()).get(); }
} else { String type = req.param("type").value("*"); MetricFilter filter = req.param("name").toOptional() .<MetricFilter> map(name -> (n, m) -> n.startsWith(name)) .orElse(MetricFilter.ALL); TimeUnit unit = TimeUnit.valueOf(req.param("unit").value("seconds").toUpperCase()); String rateUnitLabel = calculateRateUnit(unit, "ops"); double rateFactor = unit.toSeconds(1);
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); })); }
return session.unset(Pac4jConstants.REQUESTED_URL).value("/"); }); log.debug("redirecting to: {}", requestedUrl);
String page = Optional.ofNullable(req.param("theme").value(options.theme)) .map(theme -> index .replace("api-console-light-theme.css", "api-console-" + theme + "-theme.css"))
String page = Optional.ofNullable(req.param("theme").value(options.theme)) .map(theme -> index.replace("<style>", "<link rel=\"stylesheet\" " + "type=\"text/css\" href=\"" + fullStaticPath + "theme-" + theme.toLowerCase()
public void handle(final Request req, final Response rsp) throws Throwable { Clients clients = req.require(Clients.class); String clientName = req.param(clients.getClientNameParameter()).value(this.clientName);
@Override public String getRequestHeader(final String name) { return req.header(name).value(null); }
private String profileID(final boolean useSession, final Request req) { return req.<String>ifGet(Auth.ID) .orElseGet(() -> useSession ? req.session().get(Auth.ID).value(null) : null); }
@Override public Object getSessionAttribute(final String name) { Session session = req.session(); return AuthSerializer.strToObject(session.get(name).value(null)); }
} else { String type = req.param("type").value("*"); MetricFilter filter = req.param("name").toOptional() .<MetricFilter> map(name -> (n, m) -> n.startsWith(name)) .orElse(MetricFilter.ALL); TimeUnit unit = TimeUnit.valueOf(req.param("unit").value("seconds").toUpperCase()); String rateUnitLabel = calculateRateUnit(unit, "ops"); double rateFactor = unit.toSeconds(1);
return session.unset(Pac4jConstants.REQUESTED_URL).value("/"); }); log.debug("redirecting to: {}", requestedUrl);
String page = Optional.ofNullable(req.param("theme").value(options.theme)) .map(theme -> index .replace("api-console-light-theme.css", "api-console-" + theme + "-theme.css"))
public void handle(final Request req, final Response rsp) throws Throwable { Clients clients = req.require(Clients.class); String clientName = req.param(clients.getClientNameParameter()).value(this.clientName);