RevFileRegistry
abstract class RevFileRegistry(path: String) : WriteableRevFileRegistry, ReadableRevFileRegistry(source)
A registry for revisioned files, scoped under the given path.
package com.example
object AppAssets : RevFileRegistry("/assets/") {
val main: RevisionedFile = resource("main.js")
val styles: RevisionedFile = resource("styles.css")
}
fun Application.module() {
install(RevFilePlugin) {
+AppAssets
}
}
Content copied to clipboard
Functions
Link copied to clipboard
fun WriteableRevFileRegistry.file(file: File, contentType: ContentType = ContentType.defaultForFile(file), name: String = file.name): RevisionedFile
Creates a new RevisionedFile from the given file and adds it to this WriteableRevFileRegistry.
Link copied to clipboard
Returns the revisioned file associated with the given path, or null
if no such file exists.
Link copied to clipboard
Link copied to clipboard
override fun register(originalName: String, contentType: ContentType, content: OutgoingContent.ReadChannelContent): RevisionedFile
Registers and returns a revisioned file. This is the most general function to create a revisioned file.
Link copied to clipboard
fun WriteableRevFileRegistry.resource(resource: String, name: String = resource.substringAfterLast('/'), contentType: ContentType = ContentType.defaultForFilePath(resource), classLoader: ClassLoader = checkNotNull(this::class.java.classLoader) {
"Failed to get a class loader for loading resource '$resource'."
}): RevisionedFile
Creates a new RevisionedFile from the given JVM resource and adds it to this WriteableRevFileRegistry.
Link copied to clipboard
fun WriteableRevFileRegistry.source(originalName: String, contentType: ContentType = ContentType.defaultForFilePath(originalName), content: () -> Source): RevisionedFile
fun WriteableRevFileRegistry.source(path: Path, contentType: ContentType = ContentType.defaultForFilePath(path.toString()), originalName: String = path.name, fileSystem: FileSystem = SystemFileSystem): RevisionedFile
Creates a new RevisionedFile from the given source and adds it to this WriteableRevFileRegistry.
Link copied to clipboard
fun WriteableRevFileRegistry.uri(uri: URI, name: String = uri.toString().substringAfterLast('/'), contentType: ContentType = ContentType.defaultForFilePath(uri.path)): RevisionedFile
Creates a new RevisionedFile from the given URI and adds it to this WriteableRevFileRegistry.
Link copied to clipboard
fun WriteableRevFileRegistry.url(url: URL, name: String = url.toString().substringAfterLast('/'), contentType: ContentType = ContentType.defaultForFilePath(url.path)): RevisionedFile
Creates a new RevisionedFile from the given URL and adds it to this WriteableRevFileRegistry.