Plugins
Many applications require common functionality that is out of scope of the application logic. This could be things like logging, serialization, or authorization. All of these are provided in Ktor by means of what we call Plugins.
Add plugin dependency
A plugin might require a separate dependency. For example, the Logging plugin requires adding the ktor-client-logging
artifact in the build script:
You can learn which dependencies you need from a topic for a required plugin.
Install a plugin
To install a plugin, you need to pass it to the install
function inside a client configuration block. For example, installing the Logging
plugin looks as follows:
Configure a plugin
You can configure a plugin inside the install
block. For example, for the Logging plugin, you can specify the logger, logging level, and condition for filtering log messages:
Create a custom plugin
To learn how to create custom plugins, refer to Custom plugins.