Skip to content

Spring DSL Overview

Vladislav.Tankov edited this page May 31, 2020 · 2 revisions

Spring Boot DSL is a special serverless container with Spring Boot introspected by Kotless.

Basically, this DSL gives you access to all Spring Boot features. Note that features that require the storing of objects in static variables are not currently supported and may work incorrectly because of stateless nature of serverless functions.

HTTP's mappings should not use variables in path, since all of them a treated like a real paths and Kotless is unable to generate dynamic routes for now. We are working on alleviating this problem.

Spring Boot DSL includes:

  • Support of @RestController and @GetMapping/@PostMapping/... or @RequestMapping;
  • Support of static resources' deployment — static folder in resources will be deployed to S3 and added to CDN;
  • All other features of Spring Boot;
  • Permissions granting — annotations to grant permissions to resources in a declarative way.

The entrypoint of Spring Boot application is a class implementing io.kotless.dsl.spring.Kotless abstract class. You simply need to override its bootKlass field with a @SpringBootApplication annotated class:

@SpringBootApplication
open class Application : Kotless() {
    override val bootKlass: KClass<*> = this::class
}

@RestController
@RequestMapping("/pages/plugin")
object Plugin {
    @GetMapping("/overview")
    fun overview() = "Overview HTML"

    @GetMapping("/configuration")
    fun configuration() = "Configuration HTML"

    @GetMapping("/tasks")
    fun tasks() = "Tasks HTML"

    @GetMapping("/extensions")
    fun extensions() = "Extensions HTML"
}