Class SimpleFileSystemDirectoryRouter

java.lang.Object
com.kingsrook.qqq.middleware.javalin.routeproviders.SimpleFileSystemDirectoryRouter
All Implemented Interfaces:
QJavalinRouteProviderInterface

public class SimpleFileSystemDirectoryRouter extends Object implements QJavalinRouteProviderInterface
Route provider that serves static files and SPAs from the file system or JAR. This is a simpler alternative to IsolatedSpaRouteProvider, suitable for cases where you need basic file serving with optional SPA deep linking support but don't need the advanced isolation and handler features. Features: - Serves static files from file system or JAR classpath - Optional SPA deep linking (404 -> root file fallback) - Authentication support via RouteAuthenticatorInterface - Static asset detection to distinguish between missing assets and SPA routes Usage Examples:
 // Serve static files from dist directory
 new SimpleFileSystemDirectoryRouter("/app", "dist/")

 // Serve SPA with deep linking
 new SimpleFileSystemDirectoryRouter("/app", "dist/")
    .withSpaRootPath("/app")
    .withSpaRootFile("dist/index.html")
    .withRouteAuthenticator(new QCodeReference(AppAuthenticator.class))
 
  • Field Details

    • loadStaticFilesFromJar

      public static boolean loadStaticFilesFromJar
  • Constructor Details

    • SimpleFileSystemDirectoryRouter

      public SimpleFileSystemDirectoryRouter(String hostedPath, String fileSystemPath)
      Constructor
    • SimpleFileSystemDirectoryRouter

      public SimpleFileSystemDirectoryRouter(JavalinRouteProviderMetaData routeProvider)
      Constructor that builds router from meta-data configuration.
      Parameters:
      routeProvider - meta-data containing route configuration including hosted path, file system path, SPA settings, and authenticator
  • Method Details

    • setQInstance

      public void setQInstance(QInstance qInstance)
      Set the QInstance for this route provider. Called by the framework during initialization to provide access to the QQQ instance configuration.
      Specified by:
      setQInstance in interface QJavalinRouteProviderInterface
      Parameters:
      qInstance - the QInstance containing meta-data and configuration
    • acceptJavalinConfig

      public void acceptJavalinConfig(io.javalin.config.JavalinConfig config)
      Configure Javalin to serve static files from the configured location. Registers the static file configuration with Javalin during initialization. The actual configuration is handled by handleJavalinStaticFileConfig().
      Specified by:
      acceptJavalinConfig in interface QJavalinRouteProviderInterface
      Parameters:
      config - the Javalin configuration object
    • getRouteAuthenticator

      public QCodeReference getRouteAuthenticator()
      Getter for routeAuthenticator
      See Also:
    • setRouteAuthenticator

      public void setRouteAuthenticator(QCodeReference routeAuthenticator)
      Setter for routeAuthenticator
      See Also:
    • withRouteAuthenticator

      public SimpleFileSystemDirectoryRouter withRouteAuthenticator(QCodeReference routeAuthenticator)
      Fluent setter for routeAuthenticator
      Parameters:
      routeAuthenticator - code reference to the route authenticator implementation
      Returns:
      this
    • getSpaRootPath

      public String getSpaRootPath()
      Getter for spaRootPath
      See Also:
    • setSpaRootPath

      public void setSpaRootPath(String spaRootPath)
      Setter for spaRootPath
      See Also:
    • withSpaRootPath

      public SimpleFileSystemDirectoryRouter withSpaRootPath(String spaRootPath)
      Fluent setter for spaRootPath
      Parameters:
      spaRootPath - the URL path prefix for the SPA (e.g., "/app" or "/")
      Returns:
      this
    • getSpaRootFile

      public String getSpaRootFile()
      Getter for spaRootFile
      See Also:
    • setSpaRootFile

      public void setSpaRootFile(String spaRootFile)
      Setter for spaRootFile
      See Also:
    • withSpaRootFile

      public SimpleFileSystemDirectoryRouter withSpaRootFile(String spaRootFile)
      Fluent setter for spaRootFile
      Parameters:
      spaRootFile - path to the SPA index file for deep linking (e.g., "dist/index.html")
      Returns:
      this