Creating a Controller


One of the core capabilities of Spring Boot is to auto-discover application components based on what it finds in the classpath. Among those components are controllers, which provide the routes for a web application. In the examples in this chapter, we’ll use this facility.

Use Kofu to Explicitly Configure Applications

If you’d like to explicitly configure the application, refer to the Spring-fua initiative and the Kofu DSLb that provide a fluent syntax to configure various properties. In addition to benefiting from a fluent Kotlin API, Kofu-based applications benefit from a significantly less startup time compared to auto-configured applications.



Creating routes

Our controller needs to support three different routes/operations. Let’s start with one route. The first route we’ll create has an endpoint task, supports the GET HTTP method, and simply returns a message “to be implemented” as a starting point.

Kotlin vs. Java

We’ll name our controller TaskController. If we were writing this application in Java, our controller would look like this:

Get hands-on with 1200+ tech skills courses.