fun Route.preCompressed(vararg types: CompressedFileType = CompressedFileType.values(), configure: Route.() -> Unit)

Support pre-compressed files in the file system only (not just any classpath resource)

For example, by using preCompressed() (or preCompressed(CompressedFileType.BROTLI)), the local file /foo/ can be found @ http..../foo/bar.js

Appropriate headers will be set and compression will be suppressed if pre-compressed file is found


  • The order in types is important, it will determine the priority of serving one versus serving another

  • This can't be disabled in a child route if it was enabled in the root route