Skip to content

Spring HTTP API

Vladislav.Tankov edited this page Jun 13, 2020 · 2 revisions

Spring Boot DSL uses standard Spring Boot annotations : @RestController and @GetMapping/@PostMapping/.. or @RequestMapping to define API. Static resources will be deployed from static folder in `resources.

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"
}

Note, that Kotless itself does not extend or change Spring Boot API — just use it and let Kotless do serverless magic for you.