jooby project (#2330)
* moving jmh into libraries module * refactoring jmh * Update pom.xml * manual algorightm * with BM result * fix for space issue * Fixed indentation * change as per suggestion * vavr either * adding unit test and othe rutilities * adding concurrent module * concurrent package description * concurrent package description * Update EitherUnitTest.java * introducing lambda expression * jooby project * jooby project
This commit is contained in:
committed by
Grzegorz Piwowarek
parent
5c1bf55e34
commit
244a678b46
@@ -0,0 +1,95 @@
|
||||
package com.baeldung.jooby;
|
||||
|
||||
import org.jooby.Jooby;
|
||||
import org.jooby.Mutant;
|
||||
import org.jooby.Session;
|
||||
import org.jooby.jedis.Redis;
|
||||
import org.jooby.jedis.RedisSessionStore;
|
||||
|
||||
import com.baeldung.jooby.bean.Employee;
|
||||
|
||||
public class App extends Jooby {
|
||||
|
||||
{
|
||||
port(8080);
|
||||
securePort(8443);
|
||||
}
|
||||
|
||||
{
|
||||
get("/", () -> "Hello World!");
|
||||
}
|
||||
|
||||
{
|
||||
get("/user/{id}", req -> "Hello user : " + req.param("id").value());
|
||||
get("/user/:id", req -> "Hello user: " + req.param("id").value());
|
||||
get("/uid:{id}", req -> "Hello User with id : uid" + req.param("id").value());
|
||||
}
|
||||
|
||||
{
|
||||
onStart(() -> {
|
||||
System.out.println("starting app");
|
||||
});
|
||||
|
||||
onStop(() -> {
|
||||
System.out.println("stopping app");
|
||||
});
|
||||
|
||||
onStarted(() -> {
|
||||
System.out.println("app started");
|
||||
});
|
||||
}
|
||||
|
||||
{
|
||||
get("/login", () -> "Hello from Baeldung");
|
||||
}
|
||||
|
||||
{
|
||||
post("/save", req -> {
|
||||
Mutant token = req.param("token");
|
||||
return token.intValue();
|
||||
});
|
||||
}
|
||||
|
||||
{
|
||||
{
|
||||
assets("/employee", "form.html");
|
||||
}
|
||||
|
||||
post("/submitForm", req -> {
|
||||
Employee employee = req.params(Employee.class);
|
||||
// TODO
|
||||
return "empoyee data saved successfullly";
|
||||
});
|
||||
}
|
||||
|
||||
{
|
||||
get("/filter", (req, resp, chain) -> {
|
||||
// TODO
|
||||
// resp.send(...);
|
||||
chain.next(req, resp);
|
||||
});
|
||||
get("/filter", (req, resp) -> {
|
||||
resp.send("filter response");
|
||||
});
|
||||
}
|
||||
|
||||
{
|
||||
// cookieSession();
|
||||
|
||||
// use(new Redis());
|
||||
//
|
||||
// session(RedisSessionStore.class);
|
||||
|
||||
get("/session", req -> {
|
||||
Session session = req.session();
|
||||
session.set("token", "value");
|
||||
return session.get("token").value();
|
||||
});
|
||||
}
|
||||
|
||||
public static void main(final String[] args) {
|
||||
|
||||
run(App::new, args);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.baeldung.jooby.bean;
|
||||
|
||||
public class Employee {
|
||||
|
||||
String id;
|
||||
String name;
|
||||
String email;
|
||||
String phone;
|
||||
String address;
|
||||
|
||||
public Employee(String id, String name, String email, String phone, String address) {
|
||||
super();
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.email = email;
|
||||
this.phone = phone;
|
||||
this.address = address;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.baeldung.jooby.mvc;
|
||||
|
||||
import org.jooby.Result;
|
||||
import org.jooby.Results;
|
||||
import org.jooby.mvc.GET;
|
||||
import org.jooby.mvc.Path;
|
||||
|
||||
@Path("/hello")
|
||||
public class GetController {
|
||||
|
||||
@GET
|
||||
public String hello() {
|
||||
return "Hello Baeldung";
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/home")
|
||||
public Result home() {
|
||||
return Results.html("welcome").put("model", new Object());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.baeldung.jooby.mvc;
|
||||
|
||||
import org.jooby.mvc.POST;
|
||||
import org.jooby.mvc.Path;
|
||||
|
||||
@Path("/submit")
|
||||
public class PostController {
|
||||
|
||||
@POST
|
||||
public String hello() {
|
||||
return "Submit Baeldung";
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user