From c669d7b61db18fdbdaafa30e11c24b4c2a6056c9 Mon Sep 17 00:00:00 2001 From: Edgar Espina Date: Mon, 10 Jun 2024 14:48:50 -0300 Subject: [PATCH] '3.2.0' --- index.html | 2042 +++++++++++++------------- migration/3.x/index.html | 6 +- modules/avaje-inject/index.html | 32 +- modules/avaje-jsonb/index.html | 30 +- modules/aws/index.html | 24 +- modules/caffeine/index.html | 14 +- modules/camel/index.html | 36 +- modules/ebean/index.html | 86 +- modules/flyway/index.html | 34 +- modules/freemarker/index.html | 28 +- modules/graphql/index.html | 68 +- modules/gson/index.html | 30 +- modules/guice/index.html | 32 +- modules/handlebars/index.html | 24 +- modules/hibernate/index.html | 100 +- modules/hikari/index.html | 60 +- modules/jackson/index.html | 54 +- modules/jasypt/index.html | 38 +- modules/jdbi/index.html | 82 +- modules/jstachio/index.html | 48 +- modules/jte/index.html | 34 +- modules/jwt-session-store/index.html | 14 +- modules/kafka/index.html | 18 +- modules/metrics/index.html | 72 +- modules/node/index.html | 30 +- modules/openapi/index.html | 86 +- modules/pac4j/index.html | 94 +- modules/pebble/index.html | 24 +- modules/quartz/index.html | 82 +- modules/redis/index.html | 36 +- modules/rocker/index.html | 42 +- modules/thymeleaf/index.html | 26 +- modules/whoops/index.html | 14 +- modules/yasson/index.html | 30 +- packaging/index.html | 16 +- usage/index.html | 32 +- 36 files changed, 1721 insertions(+), 1797 deletions(-) diff --git a/index.html b/index.html index c7799db..08bb1d8 100644 --- a/index.html +++ b/index.html @@ -932,7 +932,7 @@

Welcome!!
Java
Kotlin
Java
Kotlin
Java
Kotlin
Java
Kotlin
-
import io.jooby.annotation.*;
+
import io.jooby.annotation.*;
 
 public class MyController {
 
@@ -1124,9 +1124,9 @@ 

+}
Creates a Maven Kotlin project:
-
jooby> create myapp --kotlin
+
jooby> create myapp --kotlin
@@ -1312,13 +1312,13 @@

Creates a Gradle Java project:
-
jooby> create myapp --gradle
+
jooby> create myapp --gradle
Creates a Gradle Kotlin project:
-
jooby> create myapp --gradle --kotlin
+
jooby> create myapp --gradle --kotlin
Java
Kotlin
-
{
+
{
   get("/", ctx -> "Snippet");
-}
+}
Java
Kotlin
@@ -1621,21 +1621,21 @@

Single path variable:
Java
Kotlin
-
{
+
{
   (1)
   get("/user/{id}", ctx -> {
     int id = ctx.path("id").intValue(); (2)
     return id;
   });
-}
+}
Java
Kotlin
-
{
+
{
   (1)
   get("/file/{file}.{ext}", ctx -> {
     String filename = ctx.path("file").value(); (2)
     String ext = ctx.path("ext").value();   (3)
     return filename + "." + ext;
   });
-}
+}
Java
Kotlin
-
{
+
{
   (1)
   get("/profile/{id}?", ctx -> {
     String id = ctx.path("id").value("self"); (2)
     return id;
   });
-}
+}
Java
Kotlin
-
{
+
{
   (1)
   get("/user/{id:[0-9]+}", ctx -> {
     int id = ctx.path("id").intValue(); (2)
     return id;
   });
-}
+}
Java
Kotlin
-
interface Filter {
+
interface Filter {
   Handler apply(Handler next);
-}
+}
-
interface Before {
+
interface Before {
   void apply(Context ctx);
-}
+}
@@ -2082,16 +2082,16 @@

-
interface After {
+
interface After {
   void apply(Context ctx, Object result, Throwable failure);
-}
+}
Functional Handler:
Java
Kotlin
-
{
+
{
   after((ctx, result, failure) -> {
     System.out.println(result);          (1)
     ctx.setResponseHeader("foo", "bar"); (2)
@@ -2100,9 +2100,9 @@ 

+}
@@ -2136,7 +2136,7 @@

Side-Effect Handler:

Java
Kotlin
-
{
+
{
   after((ctx, result, failure) -> {
     System.out.println(result);          (1)
     ctx.setResponseHeader("foo", "bar"); (2)
@@ -2145,9 +2145,9 @@ 

+}
@@ -2184,7 +2184,7 @@

Safe After:

Java
Kotlin
-
{
+
{
   after((ctx, result, failure) -> {
     if (ctx.isResponseStarted()) {
       // Don't modify response
@@ -2192,9 +2192,9 @@ 

+}
@@ -2228,7 +2228,7 @@

Run code depending of success or failure responses:

Java
Kotlin
-
{
+
{
   after((ctx, result, failure) -> {
     if (failure == null) {
       db.commit();                   (1)
@@ -2236,9 +2236,9 @@ 

(2) } }); -}

+}
@@ -2256,21 +2256,21 @@

Recover fom exception and produces an alternative output:

Java
Kotlin
-
{
+
{
   after((ctx, result, failure) -> {
     if (failure instanceOf MyBusinessException) {
       ctx.send("Recovering from something");        (1)
     }
   });
-}
+}
@@ -2291,7 +2291,7 @@

Suppressed exceptions:

Java
Kotlin
-
{
+
{
   after((ctx, result, failure) -> {
     ...
     throw new AnotherException();
@@ -2306,9 +2306,9 @@ 

(1) Throwable anotherException = failure.getSuppressed()[0]; (2) }); -}

+}
@@ -2353,7 +2353,7 @@

Example

Java
Kotlin
Java
Kotlin
-
{
+
{
   routes(() -> {
 
     get("/", ctx -> "Hello");
 
   });
-}
+}
Java
Kotlin
Java
Kotlin
Java
Kotlin
Java
Kotlin
@@ -2969,7 +2969,7 @@

Dynamic Routing
Java
Kotlin
Java
Kotlin
-
import io.jooby.Jooby;
+
import io.jooby.Jooby;
 ...
 {
 
   setHiddenMethod(ctx -> ctx.header("X-HTTP-Method-Override").toOptional());  (1)
-}
+}
Java
Kotlin
Java
Kotlin
Java
Kotlin
@@ -4046,7 +4046,7 @@

Java
Kotlin
Java
Kotlin
-
{
+
{
   post("/string", ctx -> {
     String body = ctx.body().value();        (1)
     ...
@@ -4735,9 +4735,9 @@ 

(3) ... }); -}

+}
Java
Kotlin
@@ -4888,7 +4888,7 @@

<
Response body
Java
Kotlin
Java
Kotlin
@@ -5054,8 +5054,7 @@

5. MVC API

-

MVC API is an alternative way to define routes in Jooby. It uses annotations and byte code generation -to define and execute routes.

+

MVC API is an alternative way to define routes in Jooby. It generates source code to define and execute routes.

If you use Gradle 6.0 or a later version, you can leverage incremental annotation processing support, @@ -5069,20 +5068,20 @@

build.gradle

Java
Kotlin
-
tasks.withType(JavaCompile) {
+
tasks.withType(JavaCompile) {
     options.compilerArgs += [
         '-parameters',
         '-Ajooby.incremental=true',
         '-Ajooby.services=true'
     ]
-}
+}
Java
Kotlin
@@ -5191,103 +5190,28 @@

Simple MVC route registration
Java
Kotlin
-
public class App extends Jooby {
+
public class App extends Jooby {
   {
-    mvc(new MyController());
-  }
-
-  public static void main(String[] args) {
-    runApp(args, App::new);
-  }
-}
-
- -
-

The mvc(Object) install the mvc route. As showed in the example there is -no dependency injection involved, you just instantiate a MVC route and register.

-
-
-
Class MVC route registration
- -
Java
Kotlin
-
public class App extends Jooby {
-  {
-    mvc(MyController.class);
-  }
-
-  public static void main(String[] args) {
-    runApp(args, App::new);
-  }
-}
-
- -
-

The mvc(Class) does the same job, but delegates route instantiation to a -dependency injection framework of your choice.

-
-
- - - - - -
- - -Jooby 1.x was built around Guice, this is not the case for 2.x. The entire project was built -without dependency injection. This make DI optional and at same time give you freedom to choose the -one you like most. -
-
-
-
Provider MVC route registration
- -
Java
Kotlin
-
import jakarta.inject.Provider;
-
-public class App extends Jooby {
-  {
-    Provider<MyController> provider = ...;
-
-    mvc(MyController.class, provider);
+    mvc(new MyController_());
   }
 
   public static void main(String[] args) {
     runApp(args, App::new);
   }
-}
+}
-

The mvc(Provider) does the same job, might or might not delegate -instantiation to a dependency injection framework but most important let you control lifecycle of -MVC routes (Singleton vs Non-Singleton routes).

+

The mvc(MvcExtension) install the mvc route. The generated controller instantiate the controller +or requires it when an jakarta.inject.Inject annotated controller is present.

-

There is also a Param annotation which allows to retrieve parameters from +

There is also a Param annotation which allows to retrieve parameters from multiple sources.

5.3.1. Header

-

Provisioning of headers is available via HeaderParam annotation:

+

Provisioning of headers is available via HeaderParam annotation:

Headers
Java
Kotlin
-
public class MyController {
+
public class MyController {
 
   @GET
   public Object provisioning(@HeaderParam String token) {  (1)
     ...
   }
-}
+}
@@ -5341,48 +5265,48 @@

Non valid Java name

Java
Kotlin
-
public class MyController {
+
public class MyController {
 
   @GET
   public Object provisioning(@HeaderParam("Last-Modified-Since") long lastModifiedSince) {
     ...
   }
-}
+}
-

Provisioning of cookies is available via CookieParam annotation:

+

Provisioning of cookies is available via CookieParam annotation:

Cookies
Java
Kotlin
-
public class MyController {
+
public class MyController {
 
   @GET
   public Object provisioning(@CookieParam String token) {  (1)
     ...
   }
-}
+}
@@ -5401,104 +5325,104 @@
Java
Kotlin
-
public class MyController {
+
public class MyController {
 
   @GET
   public Object provisioning(@CookieParam("token-id") String tokenId) {
     ...
   }
-}
+}

5.3.3. Path

-

For path parameters the PathParam annotation is required:

+

For path parameters the PathParam annotation is required:

PathParam
Java
Kotlin
-
public class MyController {
+
public class MyController {
 
   @Path("/{id}")
   public Object provisioning(@PathParam String id) {
     ...
   }
-}
+}

5.3.4. Query

-

For query parameters the QueryParam annotation is required:

+

For query parameters the QueryParam annotation is required:

QueryParam
Java
Kotlin
-
public class MyController {
+
public class MyController {
 
   @Path("/")
   public Object provisioning(@QueryParam String q) {
     ...
   }
-}
+}

5.3.5. Formdata/Multipart

-

For formdata/multipart parameters the FormParam annotation is required:

+

For formdata/multipart parameters the FormParam annotation is required:

QueryParam
Java
Kotlin
-
public class MyController {
+
public class MyController {
 
   @Path("/")
   @POST
   public Object provisioning(@FormParam String username) {
     ...
   }
-}
+}
@@ -5511,50 +5435,50 @@

HTTP Body
Java
Kotlin
-
public class MyController {
+
public class MyController {
 
   @Path("/")
   @POST
   public Object provisioning(MyObject body) {
     ...
   }
-}
+}

5.3.7. Flash

-

Provisioning of flash attribute is available via FlashParam annotation:

+

Provisioning of flash attribute is available via FlashParam annotation:

Flash
Java
Kotlin
-
public class MyController {
+
public class MyController {
 
   @GET
   public Object provisioning(@FlashParam String success) {  (1)
     ...
   }
-}
+}
@@ -5569,27 +5493,27 @@

5.3.8. Session

-

Provisioning of session attribute is available via SessionParam annotation:

+

Provisioning of session attribute is available via SessionParam annotation:

Session Attribute
Java
Kotlin
-
public class MyController {
+
public class MyController {
 
   @GET
   public Object provisioning(@SessionParam String userId) {  (1)
     ...
   }
-}
+}
@@ -5607,21 +5531,21 @@

Session Attribute

Java
Kotlin
-
public class MyController {
+
public class MyController {
 
   @GET
   public Object provisioning(Session session) {  (1)
     ...
   }
-}
+}

@@ -5639,27 +5563,27 @@

5.3.9. Context

-

Provisioning of context attributes is available via ContextParam annotation:

+

Provisioning of context attributes is available via ContextParam annotation:

Context Attribute
Java
Kotlin
-
public class MyController {
+
public class MyController {
 
   @GET
   public Object provisioning(@ContextParam String userId) {  (1)
     ...
   }
-}
+}
@@ -5677,21 +5601,21 @@

Context Attributes

Java
Kotlin
-
public class MyController {
+
public class MyController {
 
   @GET
   public Object provisioning(@ContextParam Map<String, Object> attributes) {  (1)
     ...
   }
-}
+}

@@ -5706,26 +5630,26 @@

5.3.10. Multiple Sources

-

You can use the Param annotation to search for a parameter in multiple sources. +

You can use the Param annotation to search for a parameter in multiple sources. The sources and their precedence can be specified as follows:

Multiple Sources
Java
Kotlin
-
public class FooController {
+
public class FooController {
 
   @GET("/{foo}")
   public String multipleSources(@Param({ QUERY, PATH }) String foo) {
     return "foo is: " + foo;
   }
-}
+}
Java
Kotlin

Java
Kotlin
Dispatch annotation
Java
Kotlin
-
public class MyController {
+
public class MyController {
   @GET("/nonblocking")
   public String nonblocking() {  (1)
     return "I'm nonblocking";
@@ -5883,9 +5807,9 @@ 

(2) return "I'm blocking"; } -}

+}
@@ -5915,21 +5839,21 @@

-

The Dispatch annotation supports custom executor using an executor name.

+

The Dispatch annotation supports custom executor using an executor name.

Dispatch to custom executor
Java
Kotlin
-
public class MyController {
+
public class MyController {
   @GET("/blocking")
   @Dispatch("single")         (1)
   public String blocking() {
     return "I'm blocking";
   }
-}
+}
Java
Kotlin
-
{
+
{
   executor("single", Executors.newSingleThreadExecutor());
 
   mvc(new MyController());
-}
+}
Java
Kotlin
@@ -6129,13 +6053,13 @@

Classpath resources:
Java
Kotlin
-
{
+
{
   assets("/static/*"); (1)
-}
+}
Java
Kotlin
-
{
+
{
   assets("/static/*", Paths.get("www")); (1)
-}
+}
Java
Kotlin
-
{
+
{
   Path docs = Paths.get("docs"); (1)
   assets("/docs/?*", docs);      (2)
-}
+}
Java
Kotlin
-
{
+
{
   AssetSource docs = AssetSource.create(Paths.get("docs")); (1)
   assets("/docs/?*", new AssetHandler("index.html", docs)); (2)
-}
+}
@@ -6308,21 +6232,21 @@

Asset handler options:

Java
Kotlin
-
{
+
{
   AssetSource www = AssetSource.create(Paths.get("www"));
   assets("/static/*", new AssetHandler(www)
     .setLastModified(false)
     .setEtag(false)
   );
-}
+}
@@ -6332,19 +6256,19 @@

Cache control:

Java
Kotlin
-
{
+
{
   AssetSource www = AssetSource.create(Paths.get("www"));
   assets("/static/*", new AssetHandler(www)
     .setMaxAge(Duration.ofDays(365))
   );
-}
+}
@@ -6359,7 +6283,7 @@

Per-asset cache control:

Java
Kotlin
-
{
+
{
   AssetSource www = AssetSource.create(Paths.get("www"));
   assets("/static/*", new AssetHandler(www)
       .cacheControl(path -> {
@@ -6373,9 +6297,9 @@ 

+}
@@ -6403,23 +6327,23 @@

Java
Kotlin
-
{
+
{
   install(new MyTemplateEngineModule());            (1)
 
   get("/", ctx -> {
     MyModel model = ...;                (2)
     return new ModelAndView("index.html", model);  (3)
   });
-}
+}
Java
Kotlin
Java
Kotlin
Java
Kotlin
Java
Kotlin
Java
Kotlin
@@ -6932,7 +6856,7 @@

WebSocket
Java
Kotlin
Java
Kotlin
-
{
+
{
   ws("/ws/{key}", (ctx, configurer) -> {
     String key = ctx.path("key").value();           (1)
     String foo = ctx.session().get("foo").value();  (2)
     ...
   });
-}
+}
Java
Kotlin
Java
Kotlin
Java
Kotlin
-
{
+
{
   sse("/sse", sse -> {            (1)
     sse.send("Welcome");          (2)
   });
-}
+}
Java
Kotlin
Java
Kotlin
-
{
+
{
   sse("/sse", sse -> {
     sse.onClose(() -> {
       // clean up
     });
   });
-}
+}
@@ -7273,17 +7197,17 @@

Keep Alive
Java
Kotlin
-
{
+
{
   sse("/sse", sse -> {
     sse.keepAlive(15, TimeUnit.SECONDS)
   });
-}
+}
@@ -7495,7 +7419,7 @@

Java
Kotlin
@@ -7804,21 +7728,21 @@

Generate a JSON String from handler
Java
Kotlin
-
{
+
{
   get("/json", ctx -> {
     ctx.setContentType(MediaType.json);
     return "{\"message\": \"Hello Raw Response\"}";
   });
-}
+}
Java
Kotlin
Java
Kotlin
@@ -7935,7 +7859,7 @@

File download example
Java
Kotlin
Java
Kotlin
@@ -8021,7 +7945,7 @@

<
In event loop
Java
Kotlin
@@ -8294,7 +8218,7 @@
Java
Kotlin
@@ -8407,7 +8331,7 @@
Java
Kotlin
@@ -8519,7 +8443,7 @@
Fl
Java
Kotlin
Java
Kotlin
-
{
+
{
   get("/", ctx -> {
     return ctx.send("Hello World!");
   });
-}
+}
Java
Kotlin
-
{
+
{
   error((ctx, cause, statusCode) -> {                                      (1)
     Router router = ctx.getRouter();
     router.getLog().error("found `{}` error", statusCode.value(), cause);  (2)
     ctx.setResponseCode(statusCode);
     ctx.send("found `" + statusCode.value() + "` error");                  (3)
   });
-}
+}
Java
Kotlin
Java
Kotlin
-
import static io.jooby.StatusCode.NOT_FOUND;
+
import static io.jooby.StatusCode.NOT_FOUND;
 {
   error(NOT_FOUND, (ctx, cause, statusCode) -> {
     ctx.send(statusCode);   (1)
   });
-}
+}
Java
Kotlin
-
{
+
{
   error(MyException.class, (ctx, cause, statusCode) -> {
     // log and process MyException
   });
-}
+}
@@ -9104,7 +9028,7 @@

Usage
Java
Kotlin
Java
Kotlin
-
import io.jooby.Jooby;
+
import io.jooby.Jooby;
 import io.jooby.CorsHandler;
 ...
 {
@@ -9227,9 +9151,9 @@ 

+}
@@ -9277,7 +9201,7 @@

Cors options

Java
Kotlin
-
import io.jooby.Jooby;
+
import io.jooby.Jooby;
 import io.jooby.CorsHandler;
 ...
 {
@@ -9289,9 +9213,9 @@ 

+}
@@ -9325,21 +9249,21 @@

application.conf
-
cors {
+
cors {
   origin: "*"
   credentials: true
   methods: [GET, POST],
   headers: [Content-Type],
   maxAge: 30m
   exposedHeaders: [Custom-Header]
-}
+}

Loading options
Java
Kotlin
-
import io.jooby.Jooby;
+
import io.jooby.Jooby;
 import io.jooby.CorsHandler;
 ...
 {
@@ -9350,9 +9274,9 @@ 

+}
@@ -9393,10 +9317,10 @@

CSRF
-
<form method="POST" action="...">
+
<form method="POST" action="...">
     <input name="csrf" value="{{csrf}}" type="hidden" />
     ...
-</form>
+</form>

@@ -9446,7 +9370,7 @@

Example

Java
Kotlin
Java
Kotlin
-
import io.jooby.Jooby;
+
import io.jooby.Jooby;
 import io.jooby.HeadHandler;
 ...
 {
@@ -9522,9 +9446,9 @@ 

+}
@@ -9563,32 +9487,32 @@

Maven
Gradle

10 requests per minute
Java
Kotlin
-
{
+
{
   Bandwidth limit = Bandwidth.simple(10, Duration.ofMinutes(1));
   Bucket bucket = Bucket4j.builder().addLimit(limit).build();     (1)
 
   before(new RateLimitHandler(bucket));                           (2)
-}
+}
Java
Kotlin
-
{
+
{
   before(new RateLimitHandler(remoteAddress -> {
     Bandwidth limit = Bandwidth.simple(10, Duration.ofMinutes(1));
     return Bucket4j.builder().addLimit(limit).build();
   }));
-}
+}
10 requests per minute per header value
Java
Kotlin
-
{
+
{
   before(new RateLimitHandler(key -> {
     Bandwidth limit = Bandwidth.simple(10, Duration.ofMinutes(1));
     return Bucket4j.builder().addLimit(limit).build();
   }, "ApiKey"));
-}
+}
10 requests per minute
Java
Kotlin
-
{
+
{
   Bandwidth limit = Bandwidth.simple(10, Duration.ofMinutes(1));
   Bucket bucket = Bucket4j.builder().addLimit(limit).build();     (1)
 
   before(new RateLimitHandler(bucket));                           (2)
-}
+}
Java
Kotlin
-
{
+
{
   ProxyManager<String> buckets = ...;
   before(RateLimitHandler.cluster(key -> {
     return buckets.getProxy(key, () -> {
       return ...;
     });
   }));
-}
+}
@@ -9708,7 +9632,7 @@

<
Force SSL
Java
Kotlin
-
import io.jooby.Jooby;
+
import io.jooby.Jooby;
 import io.jooby.SSLHandler;
 ...
 {
@@ -9720,9 +9644,9 @@ 

< get("/", ctx -> { return ctx.getScheme(); }); -}

+}

@@ -9757,7 +9681,7 @@

<
Force SSL
Java
Kotlin
-
import io.jooby.Jooby;
+
import io.jooby.Jooby;
 import io.jooby.SSLHandler;
 ...
 {
@@ -9769,9 +9693,9 @@ 

< get("/", ctx -> { return ctx.getScheme(); }); -}

+}

Java
Kotlin
-
{
+
{
   Environment env = getEnvironment();
-}
+}
Property access
Java
Kotlin
-
{
+
{
   Environment env = getEnvironment();                (1)
   Config conf = env.getConfig();             (2)
   System.out.println(conf.getString("foo")); (3)
-}
+}
application.conf
-
foo = foo
-bar = devbar
+
foo = foo
+bar = devbar
application.prod.conf
-
bar = prodbar
+
bar = prodbar
Java
Kotlin
-
{
+
{
   Environment env = setEnvironmentOptions(new EnvOptions() (1)
     .setFilename("myapp.conf")
   )
-}
+}
Java
Kotlin
-
{
+
{
   Config conf = ConfigFatory.load("/path/to/myapp.conf");  (1)
   Environment env = new Env(customConfig, "prod");         (2)
   setEnvironment(env);                                     (3)
-}
+}
-
<dependency>
+
<dependency>
   <groupId>io.jooby</groupId>
   <artifactId>jooby-test</artifactId>
   <version>3.2.0</version>
-</dependency>
+</dependency>
@@ -10544,19 +10468,19 @@

App

Java
Kotlin
-
public class App extends Jooby {
+
public class App extends Jooby {
   {
     get("/", ctx -> "Easy unit testing!");
   }
-}
+}
@@ -10566,7 +10490,7 @@

TestApp

Java
Kotlin
-
import io.jooby.test.MockRouter;
+
import io.jooby.test.MockRouter;
 
 public class TestApp {
 
@@ -10575,9 +10499,9 @@ 

+}
@@ -10600,29 +10524,29 @@

App

Java
Kotlin
-
public class App extends Jooby {
+
public class App extends Jooby {
   {
     get("/", ctx -> ctx
         .setResponseCode(StatusCode.OK)
         .send("Easy unit testing")
     );
   }
-}
+}
Checking response metadata
Java
Kotlin
-
public class TestApp {
+
public class TestApp {
 
   @Test
   public void test() {
@@ -10632,9 +10556,9 @@ 

+}
@@ -10654,28 +10578,28 @@

App

Java
Kotlin
-
public class App extends Jooby {
+
public class App extends Jooby {
   {
     post("/", ctx -> {
       String name = ctx.form("name").value();
       return name;
     });
   }
-}
+}
Using mock context
Java
Kotlin
-
public class TestApp {
+
public class TestApp {
 
   @Test
   public void test() {
@@ -10687,9 +10611,9 @@ 

+}
@@ -10711,7 +10635,7 @@

Mockito Context

Java
Kotlin
-
import static org.mockito.Mockito.mock;
+
import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
 public class TestApp {
@@ -10728,9 +10652,9 @@ 

+}
@@ -10790,13 +10714,13 @@

Maven
Gradle

Java
Kotlin
-
public class App extends Jooby {
+
public class App extends Jooby {
   {
     get("/", ctx -> "Easy testing!");
   }
-}
+}
Java
Kotlin
Java
Kotlin
-
public class App extends Jooby {
+
public class App extends Jooby {
   public App(String argument) {         (1)
     get("/", ctx -> "Easy testing!");
   }
-}
+}
Java
Kotlin
@@ -11164,7 +11088,7 @@

<
pom.xml
build.gradle
-
<plugins>
+
<plugins>
   ...
   <plugin>
     <groupId>io.jooby</groupId>
@@ -11180,9 +11104,9 @@ 

< </configuration> </plugin> ... -</plugins>

+</plugins>
@@ -11269,7 +11193,7 @@

Maven
Gradle

-
<build>
+
<build>
   <plugins>
     ...
     <plugin>
@@ -11296,9 +11220,9 @@ 

+</build>
@@ -11524,17 +11448,17 @@

<
Server
Java
Kotlin
-
import io.jooby.netty.NettyServer;
+
import io.jooby.netty.NettyServer;
 
 {
   install(new NettyServer());
-}
+}

@@ -11545,7 +11469,7 @@

<
Jetty Loom
Java
Kotlin
-
import io.jooby.jetty.JettyServer;
+
import io.jooby.jetty.JettyServer;
 
 import java.util.concurrent.Executors;
 
@@ -11559,9 +11483,9 @@ 

< worker.setVirtualThreadsExecutor(Executors.newVirtualThreadPerTaskExecutor()); install(new JettyServer(worker)); -}

+}

@@ -11588,7 +11512,7 @@

Server Options
Java
Kotlin
@@ -11733,17 +11657,17 @@

Hello HTTPS
Java
Kotlin
-
{
+
{
   setServerOptions(new ServerOptions()
       .setSecurePort(8443)             (1)
   );
-}
+}
@@ -11789,13 +11713,13 @@

Generates a PKCS12 certificate
-
mkcert -pkcs12 localhost
+
mkcert -pkcs12 localhost

Generates a X.509 certificate
-
mkcert localhost
+
mkcert localhost
@@ -11807,18 +11731,18 @@

X509

Java
Kotlin
-
{
+
{
   SslOptions ssl = SslOptions.x509("path/to/server.crt", "path/to/server.key");
   setServerOptions(new ServerOptions()
       .setSsl(ssl)                                                    (1)
   );
-}
+}
X509 from configuration
Java
Kotlin
-
{
+
{
   setServerOptions(new ServerOptions()
       .setSsl(SslOptions.from(getConfig()))
   );
-}
+}
@@ -11874,18 +11798,18 @@

PKCS12
Java
Kotlin
-
{
+
{
   SslOptions ssl = SslOptions.pkcs12("path/to/server.p12", "password");
   setServerOptions(new ServerOptions()
       .setSsl(ssl)                                                      (1)
   );
-}
+}
PKCS12 from configuration
Java
Kotlin
-
{
+
{
   setServerOptions(new ServerOptions()
       .setSsl(SslOptions.from(getConfig()))
   );
-}
+}
@@ -11941,7 +11865,7 @@

Client Authentication
Java
Kotlin
Mutual TLS from configuration
Java
Kotlin
-
{
+
{
   setServerOptions(new ServerOptions()
       .setSsl(SslOptions.from(getConfig()))
   );
-}
+}
@@ -12025,19 +11949,19 @@

TLS example
Java
Kotlin
-
{
+
{
   setServerOptions(new ServerOptions()
       .setSsl(new SslOptions().setProtocol("TLSv1.3", "TLSv1.2"))
   );
-}
+}
Java
Kotlin
-
{
+
{
   setServerOptions(new ServerOptions()
       .setHttp2(true)
       .setSecurePort(8433)
@@ -12123,9 +12047,9 @@ 

+}
@@ -12189,7 +12113,7 @@

Java
Kotlin

Java
Kotlin
@@ -12405,7 +12329,7 @@

MVC and Avaje Inject
Java
Kotlin
Java
Kotlin
Java
Kotlin
Java
Kotlin
Java
Kotlin
@@ -12784,7 +12708,7 @@

MVC and Guice
Java
Kotlin
@@ -13594,7 +13518,7 @@

Pipeline in 1.x
diff --git a/modules/avaje-inject/index.html b/modules/avaje-inject/index.html index 5bd0955..b224e2e 100644 --- a/modules/avaje-inject/index.html +++ b/modules/avaje-inject/index.html @@ -588,13 +588,13 @@

Maven
Gradle
-
<dependency>
+
<dependency>
   <groupId>io.jooby</groupId>
   <artifactId>jooby-avaje-inject</artifactId>
   <version>1.1.0</version>
-</dependency>
+</dependency>
Java
Kotlin
@@ -685,7 +685,7 @@

MVC and Avaje Inject
Java
Kotlin
Java
Kotlin
Java
Kotlin
-
import io.jooby.avaje.jsonb.AvajeJsonbModule;
+
import io.jooby.avaje.jsonb.AvajeJsonbModule;
 import io.avaje.jsonb.Jsonb;
 
 {
   var jsonb = Jsonb.builder().build();
 
   install(new AvajeJsonbModule(jsonb));
-}
+}
diff --git a/modules/aws/index.html b/modules/aws/index.html index c0afdda..d2b6e30 100644 --- a/modules/aws/index.html +++ b/modules/aws/index.html @@ -593,13 +593,13 @@

Maven
Gradle
-
<dependency>
+
<dependency>
   <groupId>io.jooby</groupId>
   <artifactId>jooby-awssdk-v1</artifactId>
   <version>3.2.0</version>
-</dependency>
+</dependency>
Java
Kotlin
-
public class MyRoutes extends RouteBuilder {
+
public class MyRoutes extends RouteBuilder {
 
   @Override public void configure() throws Exception {
     from("direct://foo")
         .log("{{myprop}}");
   }
-}
+}
Java
Kotlin
Java
Kotlin
-
import io.jooby.annotation.Transactional;
+
import io.jooby.annotation.Transactional;
 
 @Transactional(false)
 @GET("/")
 public void get(Context ctx) {
   // no automatic transaction management here
-}
+}
Java
Kotlin
-
import io.jooby.ebean.TransactionalRequest;
+
import io.jooby.ebean.TransactionalRequest;
 
 {
   ...
   use(new TransactionalRequest().enabledByDefault(false));
   ...
-}
+}
Java
Kotlin
Java
Kotlin
-
{
+
{
   get("/", ctx -> {
     ...
   }).attribute(Transactional.ATTRIBUTE, false);
-}
+}
@@ -903,15 +903,15 @@

<
Programmatically
Java
Kotlin
-
{
+
{
   DatabaseConfig dbConfig = ...;         (1)
   install(new EbeanModule(dbConfig));    (2)
-}
+}
@@ -929,14 +929,14 @@

<
Configuration
-
{
+
{
   ebean {
     ddl {
       generate = true
       run = true
     }
   }
-}
+}
diff --git a/modules/flyway/index.html b/modules/flyway/index.html index a40b74e..ad9293e 100644 --- a/modules/flyway/index.html +++ b/modules/flyway/index.html @@ -594,7 +594,7 @@

Maven
Gradle

diff --git a/modules/graphql/index.html b/modules/graphql/index.html index 6584581..b5febf0 100644 --- a/modules/graphql/index.html +++ b/modules/graphql/index.html @@ -607,7 +607,7 @@

Maven
Gradle
Java
Kotlin
-
import io.jooby.json.JacksonModule;
+
import io.jooby.json.JacksonModule;
 import io.jooby.graphql.GraphQLModule;
 
 {
   install(new GraphQLModule(...)
       .setSupportHttpGet(true)
   );
-}
+}
@@ -813,7 +813,7 @@

Maven
Gradle
-
<!--  JSON library-->
+
<!--  JSON library-->
 <dependency>
   <groupId>io.jooby</groupId>
   <artifactId>jooby-jackson</artifactId>
@@ -832,16 +832,16 @@ 

+</dependency>
@@ -851,7 +851,7 @@

Java
Kotlin

-
import io.jooby.json.JacksonModule;
+
import io.jooby.json.JacksonModule;
 import io.jooby.graphql.GraphQLModule;
 import io.jooby.graphql.GraphiQLModule;
 
@@ -861,9 +861,9 @@ 

(2) install(new GraphiQLModule()); (3) -}

+}
@@ -905,7 +905,7 @@

Maven
Gradle

Java
Kotlin
Java
Kotlin
-
import io.jooby.gson.GsonModule;
+
import io.jooby.gson.GsonModule;
 
 {
   Gson gson = new GsonBuilder().create();
 
   install(new GsonModule(gson));
-}
+}
diff --git a/modules/guice/index.html b/modules/guice/index.html index 057920b..88af133 100644 --- a/modules/guice/index.html +++ b/modules/guice/index.html @@ -588,13 +588,13 @@

Maven
Gradle
-
<dependency>
+
<dependency>
   <groupId>io.jooby</groupId>
   <artifactId>jooby-guice</artifactId>
   <version>3.2.0</version>
-</dependency>
+</dependency>
Java
Kotlin
@@ -692,7 +692,7 @@

MVC and Guice
Java
Kotlin
diff --git a/modules/hibernate/index.html b/modules/hibernate/index.html index fed9bb0..d1435dd 100644 --- a/modules/hibernate/index.html +++ b/modules/hibernate/index.html @@ -602,7 +602,7 @@

Maven
Gradle
Java
Kotlin
Java
Kotlin
-
import io.jooby.annotation.Transactional;
+
import io.jooby.annotation.Transactional;
 
 @Transactional(false)
 @GET("/")
 public void get(Context ctx) {
   // no automatic transaction management here
-}
+}
Java
Kotlin
-
import io.jooby.ebean.TransactionalRequest;
+
import io.jooby.ebean.TransactionalRequest;
 
 {
   ...
   use(new TransactionalRequest().enabledByDefault(false));
   ...
-}
+}
Java
Kotlin
Java
Kotlin
-
{
+
{
   get("/", ctx -> {
     ...
   }).attribute(Transactional.ATTRIBUTE, false);
-}
+}
Java
Kotlin
-
{
+
{
   get("/pets", ctx -> require(UnitOfWork.class)
       .apply(em -> em.createQuery("from Pet", Pet.class).getResultList()));
-}
+}
@@ -1014,7 +1014,7 @@

Multiple transactions

Java
Kotlin
-
{
+
{
   get("/update", ctx -> require(UnitOfWork.class)
       .apply((em, txh) -> {
         em.createQuery("from Pet", Pet.class).getResultList().forEach(pet -> {
@@ -1023,9 +1023,9 @@ 

+}
@@ -1049,7 +1049,7 @@

-
{
+
{
   get("/nope", ctx -> require(UnitOfWork.class)
       .apply(em -> {
 
@@ -1058,7 +1058,7 @@ 

+}
@@ -1066,13 +1066,13 @@

-
{
+
{
   use(new TransactionalRequest());
 
   // will lead to exception
   get("/nope", ctx -> require(UnitOfWork.class)
       .apply(em -> em.createQuery("from Pet", Pet.class).getResultList()));
-}
+}

@@ -1103,7 +1103,7 @@

application.conf
-
hibernate.hbm2ddl.auto = create
+
hibernate.hbm2ddl.auto = create

diff --git a/modules/hikari/index.html b/modules/hikari/index.html index fa82d83..9ea2222 100644 --- a/modules/hikari/index.html +++ b/modules/hikari/index.html @@ -597,13 +597,13 @@

Maven
Gradle
-
<dependency>
+
<dependency>
   <groupId>io.jooby</groupId>
   <artifactId>jooby-hikari</artifactId>
   <version>3.2.0</version>
-</dependency>
+</dependency>
@@ -675,17 +675,17 @@

Custom database prefix
Java
Kotlin
-
import io.jooby.hikari.HikariModule;
+
import io.jooby.hikari.HikariModule;
 
 {
   install(new HikariModule("mydb"));
-}
+}
Java
Kotlin
-
import io.jooby.hikari.HikariModule;
+
import io.jooby.hikari.HikariModule;
 
 {
   install(new HikariModule("jdbc:mysql://localhost/mydb"));
-}
+}
@@ -736,20 +736,20 @@

application.conf
-
maindb.url = "jdbc:mysql://localhost/main"
+
maindb.url = "jdbc:mysql://localhost/main"
 maindb.user = myuser
 maindb.password = mypass
 
 auditdb.url = "jdbc:mysql://localhost/audit"
 auditdb.user = myuser
-auditdb.password = mypass
+auditdb.password = mypass
@@ -788,10 +788,10 @@

Maximum Pool Size
-
db.url = "jdbc:mysql://localhost/main"
+
db.url = "jdbc:mysql://localhost/main"
 db.user = myuser
 
-hikari.maximumPoolSize = 10
+hikari.maximumPoolSize = 10
diff --git a/modules/jackson/index.html b/modules/jackson/index.html index 19aeb1b..cb62e98 100644 --- a/modules/jackson/index.html +++ b/modules/jackson/index.html @@ -595,13 +595,13 @@

Maven
Gradle
-
<dependency>
+
<dependency>
   <groupId>io.jooby</groupId>
   <artifactId>jooby-jackson</artifactId>
   <version>3.2.0</version>
-</dependency>
+</dependency>
Java
Kotlin
Java
Kotlin
-
import io.jooby.json.JacksonModule;
+
import io.jooby.json.JacksonModule;
 
 {
   ObjectMapper mapper = new ObjectMapper();
 
   install(new JacksonModule(mapper));
-}
+}
Java
Kotlin
-
import io.jooby.json.JacksonModule;
+
import io.jooby.json.JacksonModule;
 
 {
   install(new JacksonModule(new XmlMapper()));
-}
+}
Java
Kotlin
-
import io.jooby.json.JacksonModule;
+
import io.jooby.json.JacksonModule;
 
 {
   install(new JacksonModule(new ObjectMapper()));
   install(new JacksonModule(new XmlMapper()));
-}
+}
@@ -765,17 +765,17 @@

Provisioning Modules
Java
Kotlin
-
import io.jooby.json.JacksonModule;
+
import io.jooby.json.JacksonModule;
 
 {
   install(new JacksonModule().module(MyModule.class);
-}
+}
@@ -759,14 +759,14 @@

application.conf
-
jasypt.password = mypassword
+
jasypt.password = mypassword
 
 jasypt.algorithm = PBEWithMD5AndDES
 jasypt.keyObtentionIterations = 1000
 jasypt.poolSize = 2
 jasypt.ivGeneratorClassName = classname
 jasypt.saltGeneratorClassName = org.jasypt.salt.RandomSaltGenerator
-jasypt.providerName = SunJCE
+jasypt.providerName = SunJCE

diff --git a/modules/jdbi/index.html b/modules/jdbi/index.html index cced662..a7490f3 100644 --- a/modules/jdbi/index.html +++ b/modules/jdbi/index.html @@ -600,7 +600,7 @@

Maven
Gradle

Java
Kotlin
Java
Kotlin
-
import io.jooby.annotation.Transactional;
+
import io.jooby.annotation.Transactional;
 
 @Transactional(false)
 @GET("/")
 public void get(Context ctx) {
   // no automatic transaction management here
-}
+}
Java
Kotlin
-
import io.jooby.ebean.TransactionalRequest;
+
import io.jooby.ebean.TransactionalRequest;
 
 {
   ...
   use(new TransactionalRequest().enabledByDefault(false));
   ...
-}
+}
Java
Kotlin
Java
Kotlin
-
{
+
{
   get("/", ctx -> {
     ...
   }).attribute(Transactional.ATTRIBUTE, false);
-}
+}
@@ -894,7 +894,7 @@

SQLObjects
Java
Kotlin
@@ -943,7 +943,7 @@

<
Custom Jdbi
Java
Kotlin
diff --git a/modules/jstachio/index.html b/modules/jstachio/index.html index 6d6928b..03a92f0 100644 --- a/modules/jstachio/index.html +++ b/modules/jstachio/index.html @@ -597,20 +597,20 @@

Maven
Gradle
-
<dependency>
+
<dependency>
   <groupId>io.jooby</groupId>
   <artifactId>jooby-jstachio</artifactId>
   <version>3.2.0</version>
-</dependency>
+</dependency>
@@ -711,19 +711,19 @@

Java
Kotlin
-
{
+
{
   use(new MetricsModule());
 
   // inspected route
   get("/", context -> "Hello metrics!");
-}
+}
@@ -736,15 +736,15 @@

<
Java
Kotlin
-
{
+
{
   install(new MetricsModule()
       .threadDump();
-}
+}
@@ -757,7 +757,7 @@

Java
Kotlin
@@ -830,15 +830,15 @@

Java
Kotlin
-
{
+
{
   install(new MetricsModule("/diag")
       .threadDump();
-}
+}
diff --git a/modules/node/index.html b/modules/node/index.html index dd18c70..38d764e 100644 --- a/modules/node/index.html +++ b/modules/node/index.html @@ -605,13 +605,13 @@

Maven
Gradle
-
<dependency>
+
<dependency>
   <groupId>io.jooby</groupId>
   <artifactId>jooby-node</artifactId>
   <version>3.2.0</version>
-</dependency>
+</dependency>
@@ -845,13 +845,13 @@

<
Maven
Gradle
-
<dependency>
+
<dependency>
   <groupId>io.swagger.core.v3</groupId>
   <artifactId>swagger-annotations</artifactId>
   <version>2.2.22</version>
-</dependency>
+</dependency>

@@ -861,7 +861,7 @@

<
Script
Java
Kotlin
-
import io.swagger.v3.oas.annotations.Operation;
+
import io.swagger.v3.oas.annotations.Operation;
 ...
 
 public class App extends Jooby {
@@ -882,9 +882,9 @@ 

< long id = ctx.path("id").longValue(); return repo.find(id); } -}

+}

@@ -944,7 +944,7 @@

OpenAPIDefinition

Java
Kotlin
@@ -1000,49 +1000,49 @@

Application level
Java
Kotlin
-
@Tag(name = "Pets", description = "Pet operations")
+
@Tag(name = "Pets", description = "Pet operations")
 class App extends Jooby {
   {
     // All routes now have the default tag: `Pets`
   }
-}
+}
Controller level
Java
Kotlin
-
@Tag(name = "Pets", description = "Pet operations")
+
@Tag(name = "Pets", description = "Pet operations")
 @Path("/pets")
 class Pets {
   // All web method now have the default tag: `Pets`
-}
+}
Method level
Java
Kotlin
-
@Tag(name = "Pets", description = "Pet operations")
+
@Tag(name = "Pets", description = "Pet operations")
 public List<Pet> list(Context ctx) {
   ...
-}
+}
Java
Kotlin
-
<dependency>
+
<dependency>
   <groupId>org.pac4j</groupId>
   <artifactId>pac4j-oidc</artifactId>
   <version>5.7.0</version>
-</dependency>
+</dependency>
@@ -691,8 +691,8 @@

application.conf
-
oidc.clientId = 167480702619-8e1lo80dnu8bpk3k0lvvj27noin97vu9.apps.googleusercontent.com
-oidc.secret = MhMme_Ik6IH2JMnAT6MFIfee
+
oidc.clientId = 167480702619-8e1lo80dnu8bpk3k0lvvj27noin97vu9.apps.googleusercontent.com
+oidc.secret = MhMme_Ik6IH2JMnAT6MFIfee

@@ -702,7 +702,7 @@

Google

Java
Kotlin
-
import io.jooby.pac4j.Pac4jModule;
+
import io.jooby.pac4j.Pac4jModule;
 
 {
   install(new Pac4jModule()
@@ -720,9 +720,9 @@ 

+}
@@ -755,13 +755,13 @@

<
Maven
Gradle
-
<dependency>
+
<dependency>
   <groupId>org.pac4j</groupId>
   <artifactId>pac4j-oauth</artifactId>
   <version>5.7.0</version>
-</dependency>
+</dependency>
@@ -824,13 +824,13 @@

Maven
Gradle
-
<dependency>
+
<dependency>
   <groupId>org.pac4j</groupId>
   <artifactId>pac4j-jwt</artifactId>
   <version>5.7.0</version>
-</dependency>
+</dependency>
Java
Kotlin
@@ -899,7 +899,7 @@

<
Java
Kotlin
Automatic configuration
-
{
+
{
 
   install(
       new Pac4jModule()
           .client("/api/*", new MyTestAuthorizer(), conf -> {...});
   );
-}
+}
Registry (or dependency injection) integration
-
{
+
{
 
   install(
       new Pac4jModule()
           .client("/api/*", MyTestAuthorizer.class, conf -> {...});
   );
-}
+}
-
import io.jooby.pac4j.Pac4jModule;
+
import io.jooby.pac4j.Pac4jModule;
 import org.pac4j.core.config.Config;
 
 {
@@ -996,9 +996,9 @@ 

+}
diff --git a/modules/pebble/index.html b/modules/pebble/index.html index 00a256a..de8601b 100644 --- a/modules/pebble/index.html +++ b/modules/pebble/index.html @@ -596,13 +596,13 @@

Maven
Gradle
-
<dependency>
+
<dependency>
   <groupId>io.jooby</groupId>
   <artifactId>jooby-pebble</artifactId>
   <version>3.2.0</version>
-</dependency>
+</dependency>
diff --git a/modules/quartz/index.html b/modules/quartz/index.html index 210d9f5..cc946d9 100644 --- a/modules/quartz/index.html +++ b/modules/quartz/index.html @@ -606,13 +606,13 @@

Maven
Gradle
-
<dependency>
+
<dependency>
   <groupId>io.jooby</groupId>
   <artifactId>jooby-quartz</artifactId>
   <version>3.2.0</version>
-</dependency>
+</dependency>
Java
Kotlin
Java
Kotlin
@@ -895,13 +895,13 @@

Maven
Gradle
-
<dependency>
+
<dependency>
   <groupId>io.jooby</groupId>
   <artifactId>jooby-hikari</artifactId>
   <version>3.2.0</version>
-</dependency>
+</dependency>
@@ -911,23 +911,23 @@

Java
Kotlin

-
import io.jooby.hikari.HikariModule;
+
import io.jooby.hikari.HikariModule;
 import io.jooby.quartz.QuartzModule;
 
 {
   install(new HikariModule());
 
   install(new QuartzModule(SampleJob.class));
-}
+}
@@ -936,11 +936,11 @@

application.conf
-
db.url = "jdbc:mysql://localhost/mydb"
+
db.url = "jdbc:mysql://localhost/mydb"
 db.user = "myuser"
 db.password = "mypassword"
 
-org.quartz.jobStore.class = org.quartz.impl.jdbcjobstore.JobStoreTX
+org.quartz.jobStore.class = org.quartz.impl.jdbcjobstore.JobStoreTX

@@ -953,8 +953,8 @@

Thread Pool
-
# Set number of threads to use, default is to use the number of available processor
-org.quartz.threadPool.threadCount = 2
+
# Set number of threads to use, default is to use the number of available processor
+org.quartz.threadPool.threadCount = 2
@@ -966,14 +966,14 @@

Custom Scheduler
-
{
+
{
 
   Scheduler scheduler = QuartzModule.newScheduler(this);
   // configure scheduler as you need it
 
   install(new QuartzModule(scheduler, SampleJob.class));
 
-}
+}

Java
Kotlin
-
import io.jooby.quartz.QuartzApp
+
import io.jooby.quartz.QuartzApp
 import io.jooby.quartz.QuartzModule;
 
 {
   install(new QuartzModule(SampleJob.class));
 
   use("/scheduler", new QuartzApp());
-}
+}
@@ -748,7 +748,7 @@

Usage
Java
Kotlin
Java
Kotlin
Java
Kotlin
-
import io.jooby.json.YassonModule;
+
import io.jooby.json.YassonModule;
 
 {
   Jsonb jsonb = JsonbBuilder.create();
 
   install(new YassonModule(jsonb));
-}
+}
diff --git a/packaging/index.html b/packaging/index.html index 73cf689..95099e4 100644 --- a/packaging/index.html +++ b/packaging/index.html @@ -610,7 +610,7 @@

Maven
Gradle
-
<build>
+
<build>
   <plugins>
     ...
     <plugin>
@@ -637,9 +637,9 @@ 

+</build>