Class ServletCompressionConfiguration

java.lang.Object
io.micronaut.servlet.engine.ServletCompressionConfiguration
All Implemented Interfaces:
io.micronaut.core.util.Toggleable

@ConfigurationProperties("micronaut.servlet.compression") public class ServletCompressionConfiguration extends Object implements io.micronaut.core.util.Toggleable
Response compression, applied by the container.

Each container compresses responses itself, so this configuration is wired to the container's own encoder rather than reimplemented as a filter: the containers already settle the cases that make compression awkward, such as HEAD, ranges, already encoded bodies and the Vary header they have to add.

Since:
6.2.0
Author:
graemerocher
  • Field Details

    • PREFIX

      public static final String PREFIX
      The configuration prefix.
      See Also:
    • DEFAULT_ENABLED

      public static final boolean DEFAULT_ENABLED
      Whether compression is enabled by default.
      See Also:
    • DEFAULT_THRESHOLD

      public static final int DEFAULT_THRESHOLD
      The default size a response must reach before it is worth compressing, in bytes.
      See Also:
  • Constructor Details

    • ServletCompressionConfiguration

      public ServletCompressionConfiguration()
  • Method Details

    • isEnabled

      public boolean isEnabled()
      Specified by:
      isEnabled in interface io.micronaut.core.util.Toggleable
      Returns:
      Whether responses are compressed when the client accepts it
    • setEnabled

      public void setEnabled(boolean enabled)
      Parameters:
      enabled - Whether responses are compressed. Default value (true)
    • getThreshold

      public int getThreshold()
      Returns:
      The size a response must reach before it is compressed, in bytes
    • setThreshold

      public void setThreshold(@ReadableBytes int threshold)
      Parameters:
      threshold - The size a response must reach before it is compressed. Default value (1024 bytes)
    • getContentTypes

      public Set<String> getContentTypes()
      Returns:
      The content types that are compressed
    • setContentTypes

      public void setContentTypes(Set<String> contentTypes)
      Parameters:
      contentTypes - The content types that are compressed