public interface AssetSource
An asset source is a collection or provider of
Asset
. There are two implementations:
- File system: using
create(Path)
. - Classpath/URL: using
create(ClassLoader, String)
.
-
Method Summary
Modifier and TypeMethodDescriptionstatic AssetSource
create
(ClassLoader loader, String location) Classpath asset source.static AssetSource
Creates a source from given location.Resolve an asset using the given path.static AssetSource
webjars
(ClassLoader loader, String name) Creates a webjar asset source.
-
Method Details
-
resolve
Resolve an asset using the given path.- Parameters:
path
- Path to look for.- Returns:
- An asset or
null
.
-
create
Classpath asset source. Useful for resolving files from classpath (including jar files).- Parameters:
loader
- Class loader.location
- Classpath location. For security reasons root of classpath/
is disallowed.- Returns:
- An asset source.
-
webjars
Creates a webjar asset source. Usage:- Add a webjar to your project, for example swagger-ui
- Create and add an asset handler:
asset("/path/*", AssetSource.webjar(getClassLoader(), "swagger-ui"));
- Parameters:
loader
- Class loader.name
- Web asset name.- Returns:
- A webjar source.
-
create
Creates a source from given location. Assets are resolved from file system.- Parameters:
location
- Asset directory.- Returns:
- A new file system asset source.
-