Java Code Examples for io.javalin.Javalin#get()
The following examples show how to use
io.javalin.Javalin#get() .
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: RestHandler.java From openmessaging-connect-runtime with Apache License 2.0 | 5 votes |
public RestHandler(ConnectController connectController){ this.connectController = connectController; Javalin app = Javalin.start(connectController.getConnectConfig().getHttpPort()); app.get("/connectors/:connectorName", this::handleCreateConnector); app.get("/connectors/:connectorName/config", this::handleQueryConnectorConfig); app.get("/connectors/:connectorName/status", this::handleQueryConnectorStatus); app.get("/connectors/:connectorName/stop", this::handleStopConnector); app.get("/getClusterInfo", this::getClusterInfo); app.get("/getConfigInfo", this::getConfigInfo); app.get("/getAllocatedInfo", this::getAllocatedInfo); }
Example 3
Source File: DefaultReportsServer.java From maestro-java with Apache License 2.0 | 5 votes |
protected void registerUris(final Javalin app) { logger.warn("Registering reports server URIs"); app.get("/api/live", ctx -> ctx.result("Hello World")); // Common usage app.get("/api/report/", new AllReportsController()); // Common usage app.get("/api/report/aggregated", new AllAggregatedReportsController()); // For the report/node specific view app.get("/api/report/report/:id", new ReportController()); app.get("/api/report/report/:id/properties", new ReportPropertiesController()); app.get("/api/report/latency/all/report/:id", new LatencyReportController()); app.get("/api/report/latency/statistics/report/:id", new LatencyStatisticsReportController()); app.get("/api/report/rate/report/:id", new RateReportController()); app.get("/api/report/rate/statistics/report/:id", new RateStatisticsReportController()); // For all tests ... context needs to be adjusted app.get("/api/report/test/:test/number/:number/properties", new TestPropertiesController()); app.get("/api/report/test/:test/sut/node", new SutNodeInfoController()); // Aggregated app.get("/api/report/latency/aggregated/test/:id/number/:number", new AggregatedLatencyReportController()); app.get("/api/report/latency/aggregated/statistics/test/:id/number/:number", new AggregatedLatencyStatisticsReportController()); app.get("/api/report/rate/:role/aggregated/test/:id/number/:number", new AggregatedRateReportController()); app.get("/api/report/rate/:role/aggregated/statistics/test/:id/number/:number", new AggregatedRateStatisticsReportController()); app.get("/api/report/:id/files", new FileListController()); app.get("/raw/report/:id/files/:name", new RawFileController()); }
Example 4
Source File: WdmServer.java From webdrivermanager with Apache License 2.0 | 5 votes |
public WdmServer(int port) { Javalin app = Javalin.create().start(port); Handler handler = this::handleRequest; app.get("/chromedriver", handler); app.get("/firefoxdriver", handler); app.get("/edgedriver", handler); app.get("/iedriver", handler); app.get("/operadriver", handler); app.get("/phantomjs", handler); app.get("/selenium-server-standalone", handler); log.info("WebDriverManager server listening on port {}", port); }
Example 5
Source File: JavalinApp.java From tutorials with MIT License | 5 votes |
public static void main(String[] args) { Javalin app = Javalin.create() .port(7000) .start(); app.get("/hello", ctx -> ctx.html("Hello, Javalin!")); app.get("/users", UserController.fetchAllUsernames); app.get("/users/:id", UserController.fetchById); }
Example 6
Source File: Endpoint.java From schedge with MIT License | 4 votes |
public final void addTo(Javalin app) { app.get(getPath(), OpenApiBuilder.documented(configureDocs(OpenApiBuilder.document()), getHandler())); }
Example 7
Source File: App.java From schedge with MIT License | 4 votes |
public static void run() { Javalin app = Javalin .create(config -> { config.enableCorsForAllOrigins(); String description = "Schedge is an API to NYU's course catalog. " + "Please note that <b>this API is currently under " + "active development and is subject to change</b>." + "<br/> <br/> If you'd like to contribute, " + "<a href=\"https://github.com/A1Liu/schedge\">check out the repository</a>."; Info info = new Info().version("1.0").title("Schedge").description( description); OpenApiOptions options = new OpenApiOptions(info).path("/swagger.json"); config.enableWebjars(); config.registerPlugin(new OpenApiPlugin(options)); }) .start(8080); Logger logger = LoggerFactory.getLogger("app"); String docs = new BufferedReader( new InputStreamReader( Javalin.class.getResourceAsStream("/index.html"))) .lines() .collect(Collectors.joining("\n")); app.get("/", OpenApiBuilder.documented(OpenApiBuilder.document().ignore(), ctx -> { ctx.contentType("text/html"); ctx.result(docs); })); new SubjectsEndpoint().addTo(app); new SchoolsEndpoint().addTo(app); new CoursesEndpoint().addTo(app); new SearchEndpoint().addTo(app); new SectionEndpoint().addTo(app); }
Example 8
Source File: PrometheusSample.java From micrometer with Apache License 2.0 | 4 votes |
public static void main(String[] args) { PrometheusMeterRegistry meterRegistry = new PrometheusMeterRegistry(PrometheusConfig.DEFAULT); // add any tags here that will apply to all metrics streaming from this app // (e.g. EC2 region, stack, instance id, server group) meterRegistry.config().commonTags("app", "javalin-sample"); new JvmGcMetrics().bindTo(meterRegistry); new JvmHeapPressureMetrics().bindTo(meterRegistry); new JvmMemoryMetrics().bindTo(meterRegistry); new ProcessorMetrics().bindTo(meterRegistry); new FileDescriptorMetrics().bindTo(meterRegistry); Javalin app = Javalin.create(config -> config.registerPlugin(new MicrometerPlugin(meterRegistry))).start(8080); // must manually delegate to Micrometer exception handler for excepton tags to be correct app.exception(IllegalArgumentException.class, (e, ctx) -> { MicrometerPlugin.EXCEPTION_HANDLER.handle(e, ctx); e.printStackTrace(); }); app.get("/", ctx -> ctx.result("Hello World")); app.get("/hello/:name", ctx -> ctx.result("Hello: " + ctx.pathParam("name"))); app.get("/boom", ctx -> { throw new IllegalArgumentException("boom"); }); app.routes(() -> { path("hi", () -> { get(":name", ctx -> ctx.result("Hello: " + ctx.pathParam("name"))); }); }); app.after("/hello/*", ctx -> { System.out.println("hello"); }); app.get("/prometheus", ctx -> ctx .contentType(TextFormat.CONTENT_TYPE_004) .result(meterRegistry.scrape())); }
Example 9
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 10
Source File: HoodieWithTimelineServer.java From hudi with Apache License 2.0 | 4 votes |
public void startService() { Javalin app = Javalin.create().start(cfg.serverPort); app.get("/", ctx -> ctx.result("Hello World")); }
Example 11
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); }
Example 12
Source File: Bench.java From FrameworkBenchmarks with BSD 3-Clause "New" or "Revised" License | 3 votes |
public static void main(String[] args) { Javalin app = Javalin.create().start(8080); app.get("/plaintext", ctx -> ctx.result("Hello, World!")); app.get("/json", ctx -> { ctx.json(Collections.singletonMap("message", "Hello, World!")); }); }