diff --git a/server/jetty/src/main/java/io/deephaven/server/jetty/JettyBackedGrpcServer.java b/server/jetty/src/main/java/io/deephaven/server/jetty/JettyBackedGrpcServer.java index 19acd0acc55..6df599f4b69 100644 --- a/server/jetty/src/main/java/io/deephaven/server/jetty/JettyBackedGrpcServer.java +++ b/server/jetty/src/main/java/io/deephaven/server/jetty/JettyBackedGrpcServer.java @@ -94,6 +94,9 @@ public JettyBackedGrpcServer( // Wire up the provided grpc filter context.addFilter(new FilterHolder(filter), "/*", EnumSet.noneOf(DispatcherType.class)); + // Set up /js-plugins/* + JsPlugins.maybeAdd(context); + // Set up websockets for grpc-web - depending on configuration, we can register both in case we encounter a // client using "vanilla" // grpc-websocket, that can't multiplex all streams on a single socket diff --git a/server/jetty/src/main/java/io/deephaven/server/jetty/JsPlugins.java b/server/jetty/src/main/java/io/deephaven/server/jetty/JsPlugins.java new file mode 100644 index 00000000000..ba4d7c99733 --- /dev/null +++ b/server/jetty/src/main/java/io/deephaven/server/jetty/JsPlugins.java @@ -0,0 +1,29 @@ +package io.deephaven.server.jetty; + +import io.deephaven.configuration.Configuration; +import org.eclipse.jetty.servlet.DefaultServlet; +import org.eclipse.jetty.servlet.ServletContextHandler; +import org.eclipse.jetty.servlet.ServletHolder; + +class JsPlugins { + + public static void maybeAdd(ServletContextHandler context) { + // Note: this would probably be better to live in JettyConfig - but until we establish more formal expectations + // for js plugin configuration and workflows, we'll keep this here. + final String resourceBase = + Configuration.getInstance().getStringWithDefault("deephaven.jsPlugins.resourceBase", null); + if (resourceBase == null) { + return; + } + context.addServlet(createServlet("js-plugins", resourceBase), "/js-plugins/*"); + } + + private static ServletHolder createServlet(String name, String resourceBase) { + final ServletHolder jsPlugins = new ServletHolder(name, DefaultServlet.class); + jsPlugins.setInitParameter("resourceBase", resourceBase); + jsPlugins.setInitParameter("pathInfoOnly", "true"); + jsPlugins.setInitParameter("dirAllowed", "false"); + jsPlugins.setAsyncSupported(true); + return jsPlugins; + } +}