Package io.ktor.server.plugins.compression

Types

Link copied to clipboard
class CompressionConfig : ConditionsHolderBuilder

A configuration for the Compression plugin.

Link copied to clipboard
interface CompressionEncoder

A Compression encoder.

Link copied to clipboard
class CompressionEncoderBuilder : ConditionsHolderBuilder

A builder for compression encoder configuration.

Link copied to clipboard
data class CompressionEncoderConfig(name: String, encoder: CompressionEncoder, conditions: List<ApplicationCall.(OutgoingContent) -> Boolean>, priority: Double)

An encoder configuration for the Compression plugin.

Link copied to clipboard
data class CompressionOptions(encoders: Map<String, CompressionEncoderConfig>, conditions: List<ApplicationCall.(OutgoingContent) -> Boolean>)

A configuration for the Compression plugin.

Link copied to clipboard
interface ConditionsHolderBuilder

A builder for conditions.

Link copied to clipboard
object DeflateEncoder : CompressionEncoder

Implementation of the deflate encoder.

Link copied to clipboard
object GzipEncoder : CompressionEncoder

Implementation of the gzip encoder.

Link copied to clipboard
object IdentityEncoder : CompressionEncoder

Implementation of the identity encoder.

Functions

Link copied to clipboard
fun ConditionsHolderBuilder.condition(predicate: ApplicationCall.(OutgoingContent) -> Boolean)

Appends a custom condition to the encoder or the Compression configuration. A predicate returns true when a response need to be compressed. If at least one condition is not met, a response isn't compressed.

Link copied to clipboard
fun CompressionConfig.deflate(block: CompressionEncoderBuilder.() -> Unit = {})

Appends the deflate encoder with the block configuration and the 0.9 priority.

Link copied to clipboard
fun ConditionsHolderBuilder.excludeContentType(vararg mimeTypes: ContentType)

Appends a content type exclusion condition to the encoder or the Compression configuration.

Link copied to clipboard
fun CompressionConfig.gzip(block: CompressionEncoderBuilder.() -> Unit = {})

Appends the gzip encoder with the block configuration.

Link copied to clipboard
fun CompressionConfig.identity(block: CompressionEncoderBuilder.() -> Unit = {})

Appends the identity encoder with the block configuration.

Link copied to clipboard
fun ConditionsHolderBuilder.matchContentType(vararg mimeTypes: ContentType)

Appends a content type condition to the encoder or the Compression configuration.

Link copied to clipboard
fun ConditionsHolderBuilder.minimumSize(minSize: Long)

Appends a minimum size condition to the encoder or the Compression configuration.

Properties

Link copied to clipboard
val Compression: RouteScopedPlugin<CompressionConfig>

A plugin that provides the capability to compress a response body. You can use different compression algorithms, including gzip and deflate, specify the required conditions for compressing data (such as a content type or response size), or even compress data based on specific request parameters.