mirror of
https://github.com/Kingsrook/qqq.git
synced 2025-07-18 05:01:07 +00:00
Added full support for defining SPAs within the metadata for a route provider (both spa hosted path, and physical file path)
This commit is contained in:
@ -135,14 +135,16 @@ public class QApplicationJavalinServer
|
|||||||
{
|
{
|
||||||
if(resource != null)
|
if(resource != null)
|
||||||
{
|
{
|
||||||
config.staticFiles.add(staticFileConfig -> {
|
config.staticFiles.add(staticFileConfig ->
|
||||||
|
{
|
||||||
staticFileConfig.hostedPath = this.frontendMaterialDashboardHostedPath;
|
staticFileConfig.hostedPath = this.frontendMaterialDashboardHostedPath;
|
||||||
staticFileConfig.directory = "/material-dashboard-overlay";
|
staticFileConfig.directory = "/material-dashboard-overlay";
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
config.staticFiles.add(staticFileConfig -> {
|
config.staticFiles.add(staticFileConfig ->
|
||||||
|
{
|
||||||
staticFileConfig.hostedPath = this.frontendMaterialDashboardHostedPath;
|
staticFileConfig.hostedPath = this.frontendMaterialDashboardHostedPath;
|
||||||
staticFileConfig.directory = "/material-dashboard";
|
staticFileConfig.directory = "/material-dashboard";
|
||||||
});
|
});
|
||||||
@ -212,10 +214,6 @@ public class QApplicationJavalinServer
|
|||||||
config.router.apiBuilder(javalinEndpointGroup);
|
config.router.apiBuilder(javalinEndpointGroup);
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// If the additional route provider has an SPA root defined, add it to the Javalin config. //
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
routeProvider.acceptJavalinConfig(config);
|
routeProvider.acceptJavalinConfig(config);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -34,8 +34,6 @@ import io.javalin.config.JavalinConfig;
|
|||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
public abstract class QJavalinRouteProvider
|
public abstract class QJavalinRouteProvider
|
||||||
{
|
{
|
||||||
private String spaRootPath = null;
|
|
||||||
|
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
** For initial setup when server boots, set the qInstance - but also,
|
** For initial setup when server boots, set the qInstance - but also,
|
||||||
** e.g., for development, to do a hot-swap.
|
** e.g., for development, to do a hot-swap.
|
||||||
@ -73,11 +71,10 @@ public abstract class QJavalinRouteProvider
|
|||||||
** accept the Javalin service object, to perform whatever setup you need,
|
** accept the Javalin service object, to perform whatever setup you need,
|
||||||
** such as setting up before/after handlers.
|
** such as setting up before/after handlers.
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
public void acceptJavalinService(Javalin service)
|
public void acceptJavalinService(Javalin service)
|
||||||
{
|
{
|
||||||
/////////////////////
|
/////////////////////
|
||||||
// noop at default //
|
// noop at default //
|
||||||
/////////////////////
|
/////////////////////
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -32,14 +32,12 @@ import com.kingsrook.qqq.backend.core.model.metadata.code.QCodeReference;
|
|||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
public class JavalinRouteProviderMetaData implements QMetaDataObject
|
public class JavalinRouteProviderMetaData implements QMetaDataObject
|
||||||
{
|
{
|
||||||
private String hostedPath;
|
private String hostedPath;
|
||||||
private String spaRootPath;
|
private String spaRootPath;
|
||||||
|
private String spaRootFile;
|
||||||
private String fileSystemPath;
|
private String fileSystemPath;
|
||||||
private String processName;
|
private String processName;
|
||||||
|
private List<String> methods;
|
||||||
private List<String> methods;
|
|
||||||
|
|
||||||
private QCodeReference routeAuthenticator;
|
private QCodeReference routeAuthenticator;
|
||||||
|
|
||||||
|
|
||||||
@ -208,6 +206,7 @@ public class JavalinRouteProviderMetaData implements QMetaDataObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
** Getter for spaRootPath
|
** Getter for spaRootPath
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
@ -238,4 +237,38 @@ public class JavalinRouteProviderMetaData implements QMetaDataObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Getter for spaRootFile
|
||||||
|
* @see #withSpaRootFile(String)
|
||||||
|
*******************************************************************************/
|
||||||
|
public String getSpaRootFile()
|
||||||
|
{
|
||||||
|
return (this.spaRootFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Setter for spaRootFile
|
||||||
|
* @see #withSpaRootFile(String)
|
||||||
|
*******************************************************************************/
|
||||||
|
public void setSpaRootFile(String spaRootFile)
|
||||||
|
{
|
||||||
|
this.spaRootFile = spaRootFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Fluent setter for spaRootFile
|
||||||
|
* @param spaRootFile TODO document this property
|
||||||
|
* @return this
|
||||||
|
*******************************************************************************/
|
||||||
|
public JavalinRouteProviderMetaData withSpaRootFile(String spaRootFile)
|
||||||
|
{
|
||||||
|
this.spaRootFile = spaRootFile;
|
||||||
|
return (this);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -48,15 +48,17 @@ import static com.kingsrook.qqq.backend.core.logging.LogUtils.logPair;
|
|||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
public class SimpleFileSystemDirectoryRouter extends QJavalinRouteProvider
|
public class SimpleFileSystemDirectoryRouter extends QJavalinRouteProvider
|
||||||
{
|
{
|
||||||
private QCodeReference routeAuthenticator;
|
public static final String LOAD_STATIC_FILES_FROM_JAR_PROPERTY = "qqq.javalin.enableStaticFilesFromJar";
|
||||||
private QInstance qInstance;
|
|
||||||
private final String fileSystemPath;
|
|
||||||
private final String hostedPath;
|
|
||||||
|
|
||||||
private static final QLogger LOG = QLogger.getLogger(SimpleFileSystemDirectoryRouter.class);
|
private static final QLogger LOG = QLogger.getLogger(SimpleFileSystemDirectoryRouter.class);
|
||||||
|
public static boolean loadStaticFilesFromJar = false;
|
||||||
|
private final String fileSystemPath;
|
||||||
|
private final String hostedPath;
|
||||||
|
private QCodeReference routeAuthenticator;
|
||||||
|
private QInstance qInstance;
|
||||||
|
private String spaRootPath;
|
||||||
|
private String spaRootFile;
|
||||||
|
|
||||||
|
|
||||||
public static final String LOAD_STATIC_FILES_FROM_JAR_PROPERTY = "qqq.javalin.enableStaticFilesFromJar";
|
|
||||||
public static boolean loadStaticFilesFromJar = false;
|
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
** Constructor
|
** Constructor
|
||||||
@ -94,6 +96,8 @@ public class SimpleFileSystemDirectoryRouter extends QJavalinRouteProvider
|
|||||||
public SimpleFileSystemDirectoryRouter(JavalinRouteProviderMetaData routeProvider)
|
public SimpleFileSystemDirectoryRouter(JavalinRouteProviderMetaData routeProvider)
|
||||||
{
|
{
|
||||||
this(routeProvider.getHostedPath(), routeProvider.getFileSystemPath());
|
this(routeProvider.getHostedPath(), routeProvider.getFileSystemPath());
|
||||||
|
setSpaRootPath(routeProvider.getSpaRootPath());
|
||||||
|
setSpaRootFile(routeProvider.getSpaRootFile());
|
||||||
setRouteAuthenticator(routeProvider.getRouteAuthenticator());
|
setRouteAuthenticator(routeProvider.getRouteAuthenticator());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -200,6 +204,10 @@ public class SimpleFileSystemDirectoryRouter extends QJavalinRouteProvider
|
|||||||
@Override
|
@Override
|
||||||
public void acceptJavalinConfig(JavalinConfig config)
|
public void acceptJavalinConfig(JavalinConfig config)
|
||||||
{
|
{
|
||||||
|
if(this.getSpaRootPath() != null && !this.getSpaRootPath().isEmpty())
|
||||||
|
{
|
||||||
|
config.spaRoot.addFile(this.spaRootPath, this.spaRootFile);
|
||||||
|
}
|
||||||
config.staticFiles.add(this::handleJavalinStaticFileConfig);
|
config.staticFiles.add(this::handleJavalinStaticFileConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -253,4 +261,74 @@ public class SimpleFileSystemDirectoryRouter extends QJavalinRouteProvider
|
|||||||
return (this);
|
return (this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Getter for spaRootPath
|
||||||
|
* @see #withSpaRootPath(String)
|
||||||
|
*******************************************************************************/
|
||||||
|
public String getSpaRootPath()
|
||||||
|
{
|
||||||
|
return (this.spaRootPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Setter for spaRootPath
|
||||||
|
* @see #withSpaRootPath(String)
|
||||||
|
*******************************************************************************/
|
||||||
|
public void setSpaRootPath(String spaRootPath)
|
||||||
|
{
|
||||||
|
this.spaRootPath = spaRootPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Fluent setter for spaRootPath
|
||||||
|
* @param spaRootPath TODO document this property
|
||||||
|
* @return this
|
||||||
|
*******************************************************************************/
|
||||||
|
public SimpleFileSystemDirectoryRouter withSpaRootPath(String spaRootPath)
|
||||||
|
{
|
||||||
|
this.spaRootPath = spaRootPath;
|
||||||
|
return (this);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Getter for spaRootFile
|
||||||
|
* @see #withSpaRootFile(String)
|
||||||
|
*******************************************************************************/
|
||||||
|
public String getSpaRootFile()
|
||||||
|
{
|
||||||
|
return (this.spaRootFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Setter for spaRootFile
|
||||||
|
* @see #withSpaRootFile(String)
|
||||||
|
*******************************************************************************/
|
||||||
|
public void setSpaRootFile(String spaRootFile)
|
||||||
|
{
|
||||||
|
this.spaRootFile = spaRootFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Fluent setter for spaRootFile
|
||||||
|
* @param spaRootFile TODO document this property
|
||||||
|
* @return this
|
||||||
|
*******************************************************************************/
|
||||||
|
public SimpleFileSystemDirectoryRouter withSpaRootFile(String spaRootFile)
|
||||||
|
{
|
||||||
|
this.spaRootFile = spaRootFile;
|
||||||
|
return (this);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user