Module io.jooby

Interface AssetSource


public interface AssetSource
An asset source is a collection or provider of Asset. There are two implementations:
  • Method Details

    • resolve

      @Nullable Asset resolve(@NonNull String path)
      Resolve an asset using the given path.
      Parameters:
      path - Path to look for.
      Returns:
      An asset or null.
    • create

      @NonNull static AssetSource create(@NonNull ClassLoader loader, @NonNull String location)
      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

      @NonNull static AssetSource webjars(@NonNull ClassLoader loader, @NonNull String name)
      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

      @NonNull static AssetSource create(@NonNull Path location)
      Creates a source from given location. Assets are resolved from file system.
      Parameters:
      location - Asset directory.
      Returns:
      A new file system asset source.