Creating Custom Feature
is a feature instance class, which should be immutable to avoid unintended side-effects in a highly concurrent environment.Feature implementation should be thread-safe as it will be called from multiple threads.
The Feature
companion object conforms the ApplicationFeature
interface and acts as a glue to construct the actual with the right Configuration
.
fun Application.main() {
prop = "Hello" // configuration script
}
See a complete example in the custom feature sample.