Java Code Examples for io.javalin.Javalin#post()
The following examples show how to use
io.javalin.Javalin#post() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WorkerHandler.java From openmessaging-benchmark with Apache License 2.0 | 6 votes |
public WorkerHandler(Javalin app, StatsLogger statsLogger) { this.localWorker = new LocalWorker(statsLogger); app.post("/initialize-driver", this::handleInitializeDriver); app.post("/create-topics", this::handleCreateTopics); app.post("/create-producers", this::handleCreateProducers); app.post("/probe-producers", this::handleProbeProducers); app.post("/create-consumers", this::handleCreateConsumers); app.post("/pause-consumers", this::handlePauseConsumers); app.post("/resume-consumers", this::handleResumeConsumers); app.post("/start-load", this::handleStartLoad); app.post("/adjust-publish-rate", this::handleAdjustPublishRate); app.post("/stop-all", this::handleStopAll); app.get("/period-stats", this::handlePeriodStats); app.get("/cumulative-latencies", this::handleCumulativeLatencies); app.get("/counters-stats", this::handleCountersStats); app.post("/reset-stats", this::handleResetStats); }
Example 2
Source File: Server.java From selenium-jupiter with Apache License 2.0 | 4 votes |
public Server(int port) { Javalin app = Javalin.create().start(port); Config config = new Config(); AnnotationsReader annotationsReader = new AnnotationsReader(); InternalPreferences preferences = new InternalPreferences(config); Gson gson = new Gson(); final String[] hubUrl = new String[1]; final DockerDriverHandler[] dockerDriverHandler = new DockerDriverHandler[1]; String path = config.getServerPath(); final String serverPath = path.endsWith("/") ? path.substring(0, path.length() - 1) : path; final int timeoutSec = config.getServerTimeoutSec(); Handler handler = ctx -> { String requestMethod = ctx.method(); String requestPath = ctx.path(); String requestBody = ctx.body(); log.info("Server request: {} {}", requestMethod, requestPath); log.debug("body: {} ", requestBody); Session session = gson.fromJson(requestBody, Session.class); // POST /session if (session != null && session.getDesiredCapabilities() != null) { String browserName = session.getDesiredCapabilities() .getBrowserName(); String version = session.getDesiredCapabilities().getVersion(); BrowserType browserType = getBrowserType(browserName); BrowserInstance browserInstance = new BrowserInstance(config, annotationsReader, browserType, NONE, empty(), empty()); dockerDriverHandler[0] = new DockerDriverHandler(config, browserInstance, version, preferences); dockerDriverHandler[0].resolve(browserInstance, version, "", "", false); hubUrl[0] = dockerDriverHandler[0].getHubUrl().toString(); log.info("Hub URL {}", hubUrl[0]); } // exchange request-response String response = exchange( hubUrl[0] + requestPath.replace(serverPath, ""), requestMethod, requestBody, timeoutSec); log.info("Server response: {}", response); ctx.result(response); // DELETE /session/sessionId if (requestMethod.equalsIgnoreCase(DELETE) && requestPath.startsWith(serverPath + SESSION + "/")) { dockerDriverHandler[0].cleanup(); } }; app.post(serverPath + SESSION, handler); app.post(serverPath + SESSION + "/*", handler); app.get(serverPath + SESSION + "/*", handler); app.delete(serverPath + SESSION + "/*", handler); String serverUrl = String.format("http://localhost:%d%s", port, serverPath); log.info("Selenium-Jupiter server listening on {}", serverUrl); }
Example 3
Source File: RestEndpoints.java From org.hl7.fhir.core with Apache License 2.0 | 3 votes |
public void initRestEndpoints(Javalin app, CliContext cliContext, ValidationEngine validationEngine) { myUIController = new UIController(); myCliContextController = new CliContextController(cliContext); myValidationController = new ValidationController(validationEngine); app.get("/home", myUIController.renderLandingPage); app.get("/context", myCliContextController::handleGetCurrentCliContext); app.post("/context", myCliContextController::handleSetCurrentCliContext); app.post("/validate", myValidationController::handleValidationRequest); }