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

The following examples show how to use org.rapidoid.setup.App#bootstrap() . 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 5 votes vote down vote up
public static void main(String[] args) {
	App.bootstrap(args);

	String fooUpstream = "localhost:8080/foo";

	Reverse.proxy("/bar").to(fooUpstream).add();
	Reverse.proxy("/").to(fooUpstream).add();

	On.get("/foo").html("FOO");
	On.get("/foo/hi").html("FOO HI");
	On.get("/foo/hello").html("FOO HELLO");
	On.get("/bar/hi").html("BAR HI");
}
 
Example 2
Source File: Main.java    From rapidoid with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) {
	App.bootstrap(args);

	On.get("/a*").json(Req::uri);

	Reverse.proxy("/g")
		.roles("administrator")
		.cacheTTL(1000)
		.to("http://upstream1:8080", "http://upstream2:8080")
		.add();
}
 
Example 3
Source File: HttpBeanValidationTest.java    From rapidoid with Apache License 2.0 5 votes vote down vote up
@Test
public void testValidation() {
	App.path("org.rapidoid.validation");
	App.bootstrap(new String[0]);
	JPA.bootstrap(App.path());

	onlyGet("/echo?num=123");
	onlyGet("/echo");

	onlyGet("/validating?num=123");
	onlyGet("/validating");

	onlyPost("/save?num=123");
	onlyPost("/save");
}
 
Example 4
Source File: Main.java    From rapidoid with Apache License 2.0 4 votes vote down vote up
public static void main(String[] args) {
	App.bootstrap(args);
}
 
Example 5
Source File: Main.java    From rapidoid with Apache License 2.0 4 votes vote down vote up
public static void main(String[] args) {
	App.bootstrap(args);
}
 
Example 6
Source File: Main.java    From rapidoid with Apache License 2.0 4 votes vote down vote up
public static void main(String[] args) {
	App.bootstrap(args);
}
 
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) {
	App.bootstrap(args);
}
 
Example 8
Source File: Main.java    From rapidoid with Apache License 2.0 4 votes vote down vote up
public static void main(String[] args) {
	App.bootstrap(args);
}
 
Example 9
Source File: Main.java    From rapidoid with Apache License 2.0 4 votes vote down vote up
public static void main(String[] args) {
	App.bootstrap(args);
}
 
Example 10
Source File: Main.java    From rapidoid with Apache License 2.0 4 votes vote down vote up
public static void main(String[] args) {
	App.bootstrap(args);
}
 
Example 11
Source File: Main.java    From rapidoid with Apache License 2.0 4 votes vote down vote up
public static void main(String[] args) {
	App.bootstrap(args);
}
 
Example 12
Source File: Main.java    From rapidoid with Apache License 2.0 4 votes vote down vote up
public static void main(String[] args) {
	App.bootstrap(args);
}
 
Example 13
Source File: Main.java    From rapidoid with Apache License 2.0 4 votes vote down vote up
public static void main(String[] args) {
	App.bootstrap(args);
}
 
Example 14
Source File: Main.java    From rapidoid with Apache License 2.0 4 votes vote down vote up
public static void main(String[] args) {
	App.bootstrap(args);

	Boot.auth();

	On.get("/").html((req, resp) -> "this is public!");

	On.get("/manage").roles("manager").html((req, resp) -> "this is private!");

	/* Dummy login: successful if the username is the same as the password */

	My.loginProvider((req, username, password) -> username.equals(password));

	/* Gives the 'manager' role to every logged-in user */

	My.rolesProvider((req, username) -> U.set("manager"));
}
 
Example 15
Source File: Main.java    From rapidoid with Apache License 2.0 4 votes vote down vote up
public static void main(String[] args) {
	App.bootstrap(args);
}
 
Example 16
Source File: Main.java    From rapidoid with Apache License 2.0 4 votes vote down vote up
public static void main(String[] args) {
	App.bootstrap(args);
}
 
Example 17
Source File: Main.java    From rapidoid with Apache License 2.0 3 votes vote down vote up
public static void main(String[] args) {
	App.bootstrap(args);

	My.rolesProvider((req, username) -> username.equals("bob") ? U.set("manager") : U.set());

	On.get("/hey").roles("manager").json(() -> U.map("msg", "ok"));

	// generate a token
	String token = Tokens.serialize(U.map("_user", "bob"));

	// demo request, prints {"msg":"ok"}
	Self.get("/hey?_token=" + token).print();
}
 
Example 18
Source File: Main.java    From rapidoid with Apache License 2.0 3 votes vote down vote up
public static void main(String[] args) {
	App.bootstrap(args);

	Boot.jpa();

	On.get("/books").json(() -> JPA.of(Book.class).all()); // get all books

	On.post("/books").json((@Valid Book b) -> JPA.save(b)); // insert new book if valid
}
 
Example 19
Source File: Main.java    From rapidoid with Apache License 2.0 3 votes vote down vote up
public static void main(String[] args) {
	App.bootstrap(args, "profiles=mysql,foo");

	App.gui().navbar(false);

	On.get("/profiles").mvc(() -> GUI.display(Env.profiles()));

	Map<String, Object> myConfig = Conf.section("my").toMap();
	On.get("/my").mvc(() -> GUI.grid(myConfig));
}
 
Example 20
Source File: Demo.java    From rapidoid with Apache License 2.0 3 votes vote down vote up
public static void main(String[] args) {
	App.bootstrap(args, "users.admin.password=a", "secret=X");

	Boot.all();

	On.get("/length/{x}").json((String x) -> x.length());

	Self.get("/length/abc").print();
	Self.get("/hey").print();
}