RevFileRegistry

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
}
}

Constructors

Link copied to clipboard
constructor(path: String)

Functions

Link copied to clipboard
fun WriteableRevFileRegistry.create(originalName: String, contentType: ContentType = ContentType.defaultForFilePath(originalName), content: () -> OutgoingContent.ReadChannelContent): RevisionedFile

Creates a new custom RevisionedFile and adds it to this WriteableRevFileRegistry.

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
operator override fun get(path: String): RevisionedFile?

Returns the revisioned file associated with the given path, or null if no such file exists.

Link copied to clipboard
operator override fun iterator(): Iterator<RevisionedFile>
Link copied to clipboard

Registers the given entry and returns its associated 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
override fun size(): Int

Returns the number of registered files.

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
open override fun toString(): String
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.