@@ -206,3 +206,140 @@ class MyController {
206206 }
207207}
208208----
209+
210+ [id=mvc-body]
211+ ==== Body
212+
213+ Body parameter doesn't require an annotation:
214+
215+ .HTTP Body
216+ [source, java, role = "primary"]
217+ ----
218+ public class MyController {
219+
220+ @Path("/")
221+ @POST
222+ public Object provisioning(MyObject body) {
223+ ...
224+ }
225+ }
226+ ----
227+
228+ .Kotlin
229+ [source, kotlin, role = "secondary"]
230+ ----
231+ class MyController {
232+
233+ @Path("/")
234+ @POST
235+ fun provisioning(body: MyObject) : Any {
236+ ...
237+ }
238+ }
239+ ----
240+
241+ === Registration
242+
243+ Mvc routes need to be registered (no classpath scanning). Registration is done from your application
244+ class:
245+
246+ .Simple MVC route registration
247+ [source, java, role = "primary"]
248+ ----
249+ public class App extends Jooby {
250+ {
251+ mvc(new MyController());
252+ }
253+
254+ public static void main(String[] args) {
255+ run(App::new, args);
256+ }
257+ }
258+ ----
259+
260+ .Kotlin
261+ [source, kotlin, role = "secondary"]
262+ ----
263+
264+ import io.jooby.*
265+
266+ fun main(args: Array<String>) {
267+ run(args) {
268+ mvc(MyController())
269+ }
270+ }
271+ ----
272+
273+ The javadoc:Jooby[mvc, java.lang.Object] install the mvc route. As showed in the example there is
274+ no dependency injection involved, you just instantiate a MVC route and register.
275+
276+ .Class MVC route registration
277+ [source, java, role = "primary"]
278+ ----
279+ public class App extends Jooby {
280+ {
281+ mvc(MyController.class);
282+ }
283+
284+ public static void main(String[] args) {
285+ run(App::new, args);
286+ }
287+ }
288+ ----
289+
290+ .Kotlin
291+ [source, kotlin, role = "secondary"]
292+ ----
293+
294+ import io.jooby.*
295+
296+ fun main(args: Array<String>) {
297+ run(args) {
298+ mvc(MyController::class)
299+ }
300+ }
301+ ----
302+
303+ The javadoc:Jooby[mvc, java.lang.Class] does the same job, but delegates route instantiation to a
304+ dependency injection framework of your choice.
305+
306+ NOTE: Jooby 1.x was built around Guice, this is not the case for 2.x. The entire project was built
307+ without dependency injection. This make DI optional and at same time give you freedom to choose the
308+ one you like most.
309+
310+ .Provider MVC route registration
311+ [source, java, role = "primary"]
312+ ----
313+
314+ import javax.inject.Provider;
315+
316+ public class App extends Jooby {
317+ {
318+ Provider<MyController> provider = ...;
319+
320+ mvc(MyController.class, provider);
321+ }
322+
323+ public static void main(String[] args) {
324+ run(App::new, args);
325+ }
326+ }
327+ ----
328+
329+ .Kotlin
330+ [source, kotlin, role = "secondary"]
331+ ----
332+ import javax.inject.Provider
333+ import io.jooby.*
334+
335+ fun main(args: Array<String>) {
336+ run(args) {
337+ val provider = ...
338+ mvc(MyController::class, provider)
339+ }
340+ }
341+ ----
342+
343+ The javadoc:Jooby[mvc, javax.inject.Provider] does the same job, might or might not delegate
344+ instantiation to a dependency injection framework but most important let you control lifecycle of
345+ MVC routes (Singleton vs Non-Singleton routes).
0 commit comments