resource
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(source)
Creates a new RevisionedFile from the given JVM resource and adds it to this WriteableRevFileRegistry.
Example:
Assuming the following folder structure:
src
└── main
├── kotlin
│ └── com
│ └── example
│ └── AppAssets.kt
└── resources
└── main.js
Content copied to clipboard
You can create a revisioned file for main.js
:
package com.example
object AppAssets : RevFileRegistry("/assets/") {
val main = resource("main.js")
}
Content copied to clipboard
Parameters
resource
the name of the resource to load
name
the name to be used for the revisioned file
contentType
the content type to be used for the revisioned file
classLoader
the ClassLoader
to use for loading the resource
See also
Throws
if the resource cannot be loaded