This small library exposes a simple API for declaring a server plugin that can be loaded by a Kobweb server at startup.
While the Kobweb server strives to expose useful configuration support through the .kobweb/conf.yaml file, you can use
this approach to extend Ktor in ways that are not supported.
To create and register a plugin yourself:
- Add a
compileOnlydependency oncom.varabyte.kobweb:server-pluginin your project's build script. - Add implementation dependencies as needed on Ktor artifacts. You should check with Kobweb's README to see which version of Ktor it builds against.
- Create a class that implements
KobwebServerPlugin.package com.example class MyKobwebServerPlugin : KobwebServerPlugin { override fun Application.configure() { log("Placeholder log to represent configuring the Kobweb server's Ktor Application") } } - Add a
META-INF/services/com.varabyte.kobweb.server.api.KobwebServerPluginfile in your project's resources folder, and add the fully qualified name of your class to it:com.example.MyKobwebServerPlugin - Build your project (e.g.
./gradlew jar) - Copy the resulting jar file (found in
build/libs/) into the.kobweb/server/pluginsfolder found in your Kobweb application.
Be sure to familiarize yourself with the configuration already handled by the Kobweb server by reviewing the code found here.
If the flexibility provided by this plugin system isn't enough to accomplish what you need, or if you think Kobweb should have supported your use-case out of the box, please consider filing a feature request.