Java Code Examples for org.rapidoid.setup.App#run()

The following examples show how to use org.rapidoid.setup.App#run() . 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: Main.java    From rapidoid with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) {
	App.run(args);

	On.get("/hello").plain((req, resp) -> {

		req.async(); // mark asynchronous request processing

		// send part 1
		resp.chunk("part 1".getBytes());

		// after some time, send part 2 and finish
		Jobs.after(100).milliseconds(() -> {
			resp.chunk(" & part 2".getBytes());
			resp.done();
		});

		return resp;
	});
}
 
Example 2
Source File: Main.java    From rapidoid with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) {

		// first thing to do - initializing Rapidoid, without bootstrapping anything at the moment
		App.run(args); // instead of App.bootstrap(args), which might start the server

		// customizing the server address and port - before the server is bootstrapped
		On.address("0.0.0.0").port(9998);
		Admin.address("127.0.0.1").port(9999);

		// fine-tuning the HTTP server
		Conf.HTTP.set("maxPipeline", 32);
		Conf.NET.set("bufSizeKB", 16);

		// now bootstrap some components, e.g. classpath scanning (beans)
		App.scan();

		Boot.jmx()
			.adminCenter();

		// continue with normal setup
		On.get("/x").json("x");
	}
 
Example 3
Source File: Main.java    From rapidoid with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) {
	App.run(args);

	Setup setup1 = Setups.create("foo").port(2222);
	Setup setup2 = Setups.create("bar").port(3333);

	setup1.scan(FooSetupCtrl.class.getPackage().getName());
	setup2.scan(BarSetupCtrl.class.getPackage().getName());

	// demo
	HTTP.get("localhost:2222/foo").print();
	HTTP.get("localhost:3333/bar").print();
}
 
Example 4
Source File: WebShutdownTest.java    From rapidoid with Apache License 2.0 5 votes vote down vote up
@Test
public void step2() {
	App.run(new String[0]);

	On.get("/x").plain("X");

	onlyGet("/x");
}
 
Example 5
Source File: Main.java    From FrameworkBenchmarks with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public static void main(String[] args) {
	App.run(args);

	Conf.HTTP.set("maxPipeline", 128);
	Conf.HTTP.set("timeout", 0);

	new PlaintextAndJsonServer().listen(8080);
}
 
Example 6
Source File: Main.java    From FrameworkBenchmarks with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public static void main(String[] args) {
	App.run(args);

	Conf.HTTP.set("maxPipeline", 128);
	Conf.HTTP.set("timeout", 0);
	Conf.HTTP.sub("mandatoryHeaders").set("connection", false);

	On.port(8080);

	if (Env.hasAnyProfile("mysql", "postgres")) {
		setupDbHandlers();
	} else {
		setupSimpleHandlers();
	}
}
 
Example 7
Source File: Main.java    From rapidoid with Apache License 2.0 4 votes vote down vote up
public static void main(String[] args) {
	/* Initialize the configuration */
	App.run(args);

	On.get("/hi").json((Req req) -> req.data("name", "unknown"));
}