|
@@ -1,11 +1,10 @@
|
|
|
package com.techempower;
|
|
|
|
|
|
-import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import io.jooby.Jooby;
|
|
|
import io.jooby.hikari.HikariModule;
|
|
|
-import io.jooby.json.JacksonModule;
|
|
|
import io.jooby.rocker.RockerModule;
|
|
|
|
|
|
+import javax.sql.DataSource;
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
import java.sql.Connection;
|
|
|
import java.sql.PreparedStatement;
|
|
@@ -15,8 +14,6 @@ import java.util.Collections;
|
|
|
import java.util.List;
|
|
|
import java.util.StringJoiner;
|
|
|
|
|
|
-import javax.sql.DataSource;
|
|
|
-
|
|
|
import static com.techempower.Util.randomWorld;
|
|
|
import static io.jooby.ExecutionMode.EVENT_LOOP;
|
|
|
import static io.jooby.MediaType.JSON;
|
|
@@ -30,10 +27,6 @@ public class App extends Jooby {
|
|
|
private static final byte[] MESSAGE_BYTES = MESSAGE.getBytes(StandardCharsets.UTF_8);
|
|
|
|
|
|
{
|
|
|
- /** JSON: */
|
|
|
- install(new JacksonModule());
|
|
|
- ObjectMapper mapper = require(ObjectMapper.class);
|
|
|
-
|
|
|
/** Database: */
|
|
|
install(new HikariModule());
|
|
|
DataSource ds = require(DataSource.class);
|
|
@@ -47,7 +40,7 @@ public class App extends Jooby {
|
|
|
|
|
|
get("/json", ctx -> ctx
|
|
|
.setResponseType(JSON)
|
|
|
- .send(mapper.writeValueAsBytes(new Message(MESSAGE)))
|
|
|
+ .send(Json.encode(new Message(MESSAGE)))
|
|
|
);
|
|
|
|
|
|
/** Go blocking: */
|
|
@@ -67,7 +60,7 @@ public class App extends Jooby {
|
|
|
}
|
|
|
return ctx
|
|
|
.setResponseType(JSON)
|
|
|
- .send(mapper.writeValueAsBytes(result));
|
|
|
+ .send(Json.encode(result));
|
|
|
});
|
|
|
|
|
|
/** Multiple queries: */
|
|
@@ -86,7 +79,7 @@ public class App extends Jooby {
|
|
|
}
|
|
|
return ctx
|
|
|
.setResponseType(JSON)
|
|
|
- .send(mapper.writeValueAsBytes(result));
|
|
|
+ .send(Json.encode(result));
|
|
|
});
|
|
|
|
|
|
/** Updates: */
|
|
@@ -119,8 +112,8 @@ public class App extends Jooby {
|
|
|
statement.executeUpdate();
|
|
|
}
|
|
|
}
|
|
|
- ctx.setResponseType(JSON);
|
|
|
- return ctx.send(mapper.writeValueAsBytes(result));
|
|
|
+ return ctx.setResponseType(JSON)
|
|
|
+ .send(Json.encode(result));
|
|
|
});
|
|
|
|
|
|
/** Fortunes: */
|